One-to-One Doctrine with a Composite Key

I am trying to set up a relationship as shown below. Each car can have one review. The car has a primary key on 2 columns. The review refers to the car through a combined primary key. Simple, theoretically.

class Car { /** * @ORM\Id * @ORM\Column(type="string") */ private $make; /** * @ORM\Id * @ORM\Column(type="string") */ private $model; /** * * @ORM\OneToOne(targetEntity="Review", mappedBy="car", cascade={"persist"}) */ private $review; } class Review { /** * @ORM\Id * @ORM\OneToOne(targetEntity="Car", inversedBy="review") */ private $car; /** * @var @ORM\Column(type="text") */ private $text; } 

When I try to create a circuit, the following error appears.

The id column name for the link from \ Entity \ Review to \ Entity \ Car does not exist.

What am I doing wrong?

+4
source share
1 answer

After extensive research, I can say that the above structure is not supported by the doctrine, unfortunately.

+3
source

Source: https://habr.com/ru/post/1384322/


All Articles