How can I define a many to many relationship in hibernate where the intermediate table maps to a object? I.e.
Build can have another build as dependency and this dependency can be selected in other builds too. The ‘build dependency’ object should look something like:
BuildDep{
int id;
Build parent;
Build child;
....
}
mapping to the intermediate table having columns:
id, child_build_id, parent_build_id
Thank you
By definition, many-to-many associations can only be used when the association table does not have any other columns besides the foreign keys to the parent tables.
Instead, you should use two ManyToOne/OneToMany associations.
Here’s a forum topic on this subject (with an example):
http://www.coderanch.com/t/218431/ORM/databases/Hibernate-Annotations-many-many-association