我遇到了一個奇怪的問題,使用Doctrine2。與Doctrine2三重分割映射問題
,我發現了以下錯誤:
學說ORM:證實模式
[Mapping] FAIL - The entity-class 'EmailVerification' mapping is invalid:
* The referenced column name 'id' does not have a corresponding field with this
column name on the class 'OurUsers'.
[Database] OK - The database schema is in sync with the mapping files.
我的情況如下:
- 我有3個表共享一個主鍵。
- 表
Auth
其中保存user_id
PK。 - 表
OurUsers
其中Auth.user_id
是共享的PK。 - 表
EmailVerification
其中OurUsers.user_id
是共享的PK。 - 我也有
NotOurUsers
- 因此分裂。
實體的聲明如下:
/**
* @Entity
* @Table(name="auth")
*/
class Auth {
/** @Id @Column(type="integer", name="user_id") @GeneratedValue @var int */
private $id;
/* ... */
}
/**
* @Entity
* @Table(name="our_users")
*/
class OurUsers {
/**
* @Id
* @OneToOne(targetEntity="Auth")
* @JoinColumn(nullable=false, name="user_id", referencedColumnName="user_id")
* @var Auth
*/
private $id;
/* ... */
}
/**
* @Entity
* @Table(name="email_verification")
*/
class EmailVerification {
/**
* @Id
* @OneToOne(targetEntity="OurUsers")
* @JoinColumn(nullable=false, name="user_id", referencedColumnName="user_id")
* @var OurUsers
*/
private $id;
/* ... */
}
我使用Dosctrine 2.1。
btw學說2.2驗證映射是好的,但在運行時我得到與2.1相同的錯誤。
什麼,如果你改變了'referencedColumnName'在EmailVerification只是'「身份證」 '?這樣它就會引用OurUsers類中的id屬性,這個屬性指的是Auth中的user_id。我認爲這個問題肯定是在 – jere 2012-02-09 14:49:47
之前試過的,在這裏發佈 - 不工作。 – David 2012-02-12 13:03:31