我想要关联三个学说实体:
Document,AttributeKeys,AttributeValues
AttributeValues与AttributeValues具有manyToMany关联。因此,一个属性键可以具有多个可能的值,但也可以将一个值分配给不同的键。我现在想要的是,Document采用了AttributeKey和AttributeValue的组合。
例如:
AttributeKey
1 from
2 to
3 vehicle
AttributeValue
1 Berlin (manyToMany with key 1 and 2)
2 Rom (manyToMany with key 1 and 2)
3 Paris (manyToMany with key 1 and 2)
4 Car (manyToMany with key 3)
5 Ship (manyToMany with key 3)
Document
1 Application (association with Key1+Value2 and Key3+Value4)
2 Nomination (association with Key1+Value3 and Key3+Value5)
因此,AttributeKey和AttributeValue之间的关联没有问题,并且已经存在。 但是我现在想要在Document和key + value的manyToMany关联之间建立一个新关联所以我试着不是实体< - >实体关联而是实体< - >关联关联
答案 0 :(得分:0)
好的,我(希望)自己解决了这个问题:
我创建了一个新的实体AttributeKeyValue
,它将Key + Value与两个oneToMany关联之间的manyToMany关联。然后我在manyToMany
和Document
AttributeKeyValue
AppBundle\Entity\AttributeKeyValue:
type: entity
table: attribute_keys_values
repositoryClass: AppBundle\Repository\AttributeKeyValueRepository
manyToOne:
attributeKey:
targetEntity: AttributeKey
attributeValue:
targetEntity: AttributeValue
manyToMany:
documents:
targetEntity: Document
mappedBy: attributes
id:
id:
type: integer
id: true
generator:
strategy: AUTO
在实体/文件中:
manyToMany:
attributes:
targetEntity: AttributeKeyValue
inversedBy: documents
joinTable:
name: documents_attributes