Reputation: 3580
I've got two tables and a join table: 'staff', 'classification' and 'staff_classification'. In the join table I've got an extra boolean field: 'showclassification'. My annotation is as follows:
/**
* @ManyToMany(targetEntity="Staff", inversedBy="classifications")
* @JoinTable(name="staff_classifications",
* joinColumns={@JoinColumn(name="staffid", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="classificationid", referencedColumnName="id", unique=true)});
*/
Upvotes: 19
Views: 8980
Reputation: 62924
You want an entity that describes the relationship (StaffClassifications), which has OneToMany relationships with both staff and classifications.
ManyToMany doesn't allow you have any "extra" properties, because the join table is not an entity, and thus can't have any properties.
Upvotes: 32