-->
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.  [ 6 posts ] 
Author Message
 Post subject: Is it legitimate to (additionally) map a normal join table
PostPosted: Fri Mar 02, 2007 3:43 am 
Newbie

Joined: Fri Feb 02, 2007 6:55 am
Posts: 8
In a normal bidi ManyToMany association, there is a Join table.

Can I map an additional class to the Join table.
The point is, I can directly manipulate the association more efficiently.

Sure, I know that, I can do it by breaking the ManyToMany
to two bidi OneToMany with one intermediate Entity class.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 07, 2007 8:05 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Maybe using Map and @MapKeyManyToMany

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Similar situation, how would one go about it...
PostPosted: Thu Mar 08, 2007 7:34 pm 
Newbie

Joined: Mon Dec 27, 2004 8:10 pm
Posts: 7
Location: Redwood City, CA
I'm fighting through this same issue. I'm working with a legacy schema and have the following:

Customer (table)
customer_id (int)

Address(table)
address_id (int)

CustomerAddressLink (table)
customer_id (int)
address_id(int)
mailing_address (bool)
shipping_address (bool)
begin_date (date)
end_date (date)


So, I need to actually get at the data in the mapping table. I've tried mapping the Address table with the AddressLink table in a <join> element. However, I'm finding that Hibernate is actually joining the address link table twice in the generated sql, which is killing performance. I assume it's joining once to satisfy the many to many mapping, and again to populate the entity. What's the *best* way to build this mapping such that I'll still be able to use filters to filter by values in address or the link table (I don't want to use criteria because they cause an outer join, I want the addresses to be lazy loaded).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 08, 2007 9:21 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
map the association table as a regular entity

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 08, 2007 10:18 pm 
Newbie

Joined: Fri Feb 02, 2007 6:55 am
Posts: 8
Thanks!

However, if I map the association table to a new entity.
Is it valid to left the original "@ManyToMany" mapping
on the owning side and inverse side intact?

How I HAVE to change both @ManyToMany mapping to
@OneToMany mapping and referencing the new entity (Which mapped
to the association table)?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 13, 2007 6:44 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you need to change them to @OneToMay mapping since the "association entity" has a one to many assoc with the associated entities

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.