简体   繁体   English

Doctrine 2 OneToOne单向不起作用

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM