-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Reverse Engineering: ManyToMany configuration wrong?
PostPosted: Fri May 28, 2010 6:57 pm 
Beginner
Beginner

Joined: Thu Oct 04, 2007 12:22 pm
Posts: 48
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?


Top
 Profile  
 
 Post subject: Re: Reverse Engineering: ManyToMany configuration wrong?
PostPosted: Sun May 30, 2010 9:27 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
show the ddl for your "middle table"

if it doesn't have exactly two primary keys which forign key constraints relates to the two sides then it will not be noted as a many-to-many

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.