-->
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.  [ 3 posts ] 
Author Message
 Post subject: Flatten Relationship
PostPosted: Thu Apr 01, 2010 7:15 am 
Newbie

Joined: Thu Apr 16, 2009 7:09 am
Posts: 13
Hi,

I have a situation where I have a ManyToMany relationship, so to get rid of this I have created a table between these two (as I do not like seeing many-to-many's), but now I have the situation where from both sides of this relationship, I need to get the list of the destination relationship, i.e.

A - B - C

Where B is the table inbetween the many to many. So from A I want to get a collection of C and from C I want to get a collection of A, but in my application I'm not really interested in B. In the old days when I used to use EOModeler, they had a concept of flattening a relationship to get over this, do we have the same concept in Hibernate? If yes, then how is this done easily with annotations?

Thanks,
Osian


Top
 Profile  
 
 Post subject: Re: Flatten Relationship
PostPosted: Thu Apr 01, 2010 8:46 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
have a situation where I have a ManyToMany relationship, so to get rid of this ...


Why do you want get rid of the ManyToMany relationship ?

If you use class B as 'intermediate' entity (see book java persistence with hibernate, 7,2,3 Adding columns to join tables) it is not possible to navigate directly between A and C without passing through B.
(But it should be possible in some way to write an apposite user-join-query which returns you the wanted results)


Top
 Profile  
 
 Post subject: Re: Flatten Relationship
PostPosted: Thu Apr 01, 2010 8:54 am 
Newbie

Joined: Thu Apr 16, 2009 7:09 am
Posts: 13
After some more research, I have found an easy way to do it, using the @JoinTable annotation.

I can't believe that I didn't see this before, doh!!!

Thanks for your reply though :-)


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