我们先来描述一下我的情况.我正在使用Symfony2,我的实体之间的关系有问题.
我有两个链接在一起的实体.这两个实体是AssociationQuestion和AssociationPossibleAnswer.我目前正在创建一个问题软件,其中必须将左侧的一个可能答案与右侧的另一个可能答案相关联,例如在以下示例中:

目前,我正计划在类中使用两个属性来AssociationQuestion保存许多AssociationPossibleAnswer对象.第一个数组将包含左侧可能的答案,第二个数组将包含右侧可能的答案.
因此,对我来说,看起来我将有两个oneToMany关系 AssociationQuestion
AssociationQuestion:
oneToMany:
possibleAnswersLeft:
targetEntity: AssociationPossibleAnswer
mappedBy: associationQuestion
possibleAnswersRight:
targetEntity: AssociationPossibleAnswer
mappedBy: associationQuestion
Run Code Online (Sandbox Code Playgroud)
然后,在AssociationPossibleAnswer,我会有一个ManyToOne关系:
AssociationPossibleAnswer:
manyToOne:
associationQuestion:
targetEntity: AssociationQuestion
Run Code Online (Sandbox Code Playgroud)
问题是我在尝试验证我的学说时遇到以下错误.似乎你不能像我希望的那样将两个实体链接到一个......
* The field AssociationQuestion#possibleAnswersLeft is on the inverse side of a bi-directional relationship, but the specified mappedBy association on the target-entity AssociationPossibleAnswer#associationQuestion does not contain the required 'inversedBy=possibleAnswersLeft' attribute.
* The field AssociationQuestion#possibleAnswersRight is on the inverse side of a bi-directional relationship, but the specified mappedBy …Run Code Online (Sandbox Code Playgroud)