Doctrine2 One-To-Many, Unidirectional With Join Table Association Mapping

Since the Doctrine 2.0 Documentation for this seems to be kinda fucked up at the moment, here is a working exampe of a One-To-Many, Unidirectional with Join-Table Association Mapping

Scenario

A driver can have many documents, but a document has no direct Entity relation to a driver.

Solution

Use Many-To-Many to encode it properly.

Im using annotations with the ORM-Namespace since its embedded in Symfony2. Note that One-To-Many is coded throughout Many-To-Many but the unique index is set for the join table.

In my POV thats kinda confusing since there is a @One-To-Many relationship, but whatever!

Comments