[英]Doctrine 2 OneToOne Unidirectional doesn't work
I have the following OneToOne
relation inside MyEntity
: 我在
MyEntity
内部具有以下OneToOne
关系:
/**
* @ORM\OneToOne(targetEntity="StatusHistory")
* @ORM\JoinColumn(name="lastest_status_id", referencedColumnName="id")
*/
protected $lastestStatus;
The entity StatusHistory
works. 实体
StatusHistory
起作用。 The migrations:diff
command creates the files prefectly, and the database have the correct column. migrations:diff
命令可完美创建文件,并且数据库具有正确的列。
The problem is, when I do die("c: " . $this->lastestStatus)
inside MyEntity
(trying to debug a getter), it returns Namespace\\MyEntity
rather than Namespace\\StatusHistory
. 问题是,当我在
MyEntity
(尝试调试吸气剂)中执行die("c: " . $this->lastestStatus)
)时,它将返回Namespace\\MyEntity
而不是Namespace\\StatusHistory
。
What am I doing wrong? 我究竟做错了什么?
原来我忘了在查询生成器上添加->join('myEntity.lastestStatus', 'lastestStatus')
子句...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.