I used Hibernate Tools 3.1 GA and Eclipse 3.5 to reverse engineer a MySql5 Database using annotations. In case of a many-to-many association I am confused why the tools resolved them in a bad way so that I am assuming I have configured the process wrong.
There are the two tables 'Order' and 'Item' whose many/many-association is realized via the cross table 'OrderedItem'. I expected the tools to build the Order entity like this:
Code:
public class Order
{
private Set<Item> items;
...
}
instead, the tools mapped the cross table directly:
Code:
public class Order
{
private Set<OrderItem> orderItems;
...
}
The only option I saw was the "detect many-to-many associations" which does regarding to the manual:
Quote:
detectManytoMany (default:true): If true (the default) tables which are pure many-to-many link tables will be mapped as such. A pure many-to-many table is one which primary-key contains has exactly two foreign-keys pointing to other entity tables and has no other
columns.
As my 'Order' table has a composite key, this option shall (and does to my experience) no effect.
Did I oversee any option to _not_ map the cross table, so that the entities carrie only a collection of the original referenced entities?