私はYMLマッピングでDoctrineを使用しています。私は2つの実体を持っている。 1つのGroup
エンティティと1つのUser
エンティティです。Doctrine - コンポジットキーでエンティティを永続化できません
私はそれを設定しようとしていますので、User
はグループ内で一意の名前を持っています。
User
を作成し、それにGroup
を割り当てて、DBに保存することができます。しかし、同じ名前の別のGroup
をUser
に作成しようとすると、name
の一意の制約に違反しているというエラーが表示されます。
なぜそれを維持できないのですかUser
?
彼らのマッピングは次のようになります。私は最終的にこれを考え出した
Entity\Group:
type: entity
table: groups
id:
id:
type: guid
nullable: false
id: true
generator:
strategy: AUTO
fields:
name:
type: text
nullable: true
Entity\User:
type: entity
table: users
id:
group:
associationKey: true
nullable: false
name:
type: string
manyToOne:
Group:
targetEntity: Entity\Group
joinColumn:
name: group
referencedColumnName: id