How to create entities with compound key in doctrine?

0

I have a database that works with composite keys, and I'm implementing the use of the Laravel framework .

This is my bank structure: I'm using doctrine as an ORM and found that I can not automatically generate the entities of the database, since the tables have composite keys. I am using the php artisan doctrine:convert:mapping annotation ./entidades --from-database --force command. The return to this command is:

[Doctrine\ORM\Mapping\MappingException]
It is not possible to map entity 'FinContaspagar' with a composite primary key as part of the primary key of another entity 'FinContaspagarDetalhe#grupo'.

So, I'm creating the entities manually, but I've followed the doc tutorial regarding the creation of entities @ManyToOne @OneToMany mas I still can not create the relationship in the right way. Does anyone know a way or tool to generate these entities or do you have some example like this of several composite keys?

    
asked by anonymous 05.04.2017 / 16:19

1 answer

2
Using the 2+ version of doctrine a way to map your entities manually is to place @Id on your attributes that are part of your primary key, in this case there is a restriction on using @GeneratedValue, you can not use it . Home Here is the example of the framework doc itself: Compound Primary Key

    
05.04.2017 / 17:21