私たちはDoctrine v2.2.1を使用しています。 YMLによって定義されたエンティティ。Doctrine2 2つのエンティティの複数の関係
ここでは、私は与えられた関連付けをお互いに参照している2つのエンティティを持っています。
entities\User:
type: entity
table: user
oneToMany:
subjectNews:
targetEntity: entities\News
mappedBy: subjectUser
cascade: ["all"]
actionNews:
targetEntity: entities\News
mappedBy: actionUser
cascade: ["all"]
entities\News:
type: entity
table: news
manyToOne:
subjectUser:
targetEntity: entities\User
cascade: ["all"]
nullable: true
actionUser:
targetEntity: entities\User
cascade: ["all"]
nullable: true
これらの定義に従ってエンティティクラスを生成すると、エンティティ\ユーザーPHPクラスで予期しない結果が発生します。どちらが好きですか?
/**
* Add subjectNews
*
* @param entities\News $subjectNews
* @return User
*/
public function addNews(\entities\News $subjectNews)
{
$this->subjectNews[] = $subjectNews;
return $this;
}
私のエンティティのセッターメソッドは期待どおりに生成されます。ただし、エンティティ\ユーザーの追加メソッドは期待どおりに生成されません。
何か間違っていますか?または、これに対処する方法はありますか?それとも、the issue referred in the Limitations and Known Issues doc of Doctrine2と関連していますか?
平和
チェックアウト[この回答] [1] [1]のために、だろう://stackoverflow.com/questions/6299738/doctrine-symfony-multiple-one-to-many-relations-on-same-model – frail