I have ClassA set up an entity with a primary key consisting of two foreign keys but in this case iClassA mapped to the entity ClassB with one keyManyToOne relation (simple so far).
class ClassA{ /** * @var string * @ORM\Id * @ORM\Column(name="keyA", type="string", length=255) */ private $keyA; /** * @var ClassB $classB * @ORM\ManyToOne(targetEntity="ClassB", inversedBy="classAs") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="ClassB_keyB", referencedColumnName="keyB") * }) */ private $classB; } ClassB with a composite primary keyAnd this is the ClassB: keyB and key consists of foreign key from ClassC.
class ClassB{ /** * @var string * @ORM\Id * @ORM\Column(name="keyB", type="string", length=255) */ private $keyB; /** * * @var ClassC $classC * @ORM\Id * @ORM\ManyToOne(targetEntity="ClassC", inversedBy="classBs") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="ClassC_keyC", referencedColumnName="keyC") * }) */ private $classC; /** * @var ArrayCollection $classAs * @ORM\OneToMany(targetEntity="ClassA", mappedBy="classB") */ private $classAs; } // As you can notice the ClassB contains a composite primary key (2 entities and on column).
And this is the ClassC:
class ClassC{ /** * @var string * @ORM\Id * @ORM\Column(name="keyC", type="string", length=255) */ private $keyC; /** * @var ArrayCollection $classBs * @ORM\OneToMany(targetEntity="ClassB", mappedBy="classC") */ private $classBs; } Whene i triedtry to display index pageall entities of ClassA entity the errors log page of symfony (doctrineusing findAll()) indicateI get this errorexception Missing value for primary key classC on ERP\................\ClassB
This is a prototype demonstrationWhat am I missing here :)?!