1
我是Symfony Doctrine中的新手,需要一些有關Join實體的幫助。通過不是主鍵的referencedColumnName加入列 - 編號
通常柱是由主密鑰ID
/**
* User
*
* @ORM\Table(name="users")
* @ORM\Entity(repositoryClass="MainBundle\Repository\UserRepository")
* UniqueEntity("email", message="Account with email already exists.")
*/
class User implements AdvancedUserInterface, \Serializable
{
/**
* @var \MainBundle\Entity\PersonDetails
*
* @ORM\ManyToOne(targetEntity="MainBundle\Entity\Person")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="person_details_id", referencedColumnName="id", nullable=true)
* })
*/
private $personDetails = null;
加入這是確定。
但問題是,我想通過ID字段用戶實體
/**
* User
*
* @ORM\Table(name="users")
* @ORM\Entity(repositoryClass="MainBundle\Repository\UserRepository")
* UniqueEntity("email", message="Account with email already exists.")
*/
class User implements AdvancedUserInterface, \Serializable
{
/**
* @var \MainBundle\Entity\PersonDetails
*
* @ORM\ManyToOne(targetEntity="MainBundle\Entity\Person")
* @ORM\JoinColumns({
- @ORM \ JoinColumn(name = 「ID」 的加盟關係OneToOne兩列,referencedColumnName = 「USER_ID」 ,
nullable=true)
* })
*/
private $personDetails = null;
當我嘗試加入這一方式列,我得到錯誤
上缺少MainBundle \實體\ PersonDetails主鍵ID值
是否有可能比ID索引其他領域或什麼,我試圖做是不可能的?
謝謝你們。
請修復與正確的縮進你的問題的代碼,它幾乎沒有可讀性。用戶實體中的** id字段**和** primary id **之間有什麼不同?似乎有屬性丟失(即與'@ORM \ Id()')屬性...這是需要回答你的問題。 – nifr