-->
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: one-to-many using link table???
PostPosted: Fri May 22, 2009 4:38 am 
Newbie

Joined: Tue May 05, 2009 6:59 am
Posts: 2
hello every one...
i have used hibernate in some projects before and when i want to map a bidirectional one-to-many association i use a set and a foreign key, cascading (all-delete orphan) and inverse=true. I have read somewhere ( "Beginning hibernate, From novice to professional", Apress, p.87-88 ) , that i can use a link table to maintain a one-to-many association . the parent and child tables will have both foreign keys which will be the PK of the link table. also i must use a unique constraint on one of the sides (or else it would be a many to many )... i have never used that before. my question is, which is more efficient in terms of database crud functions and maintenance and why? thank you in advance.


Top
 Profile  
 
 Post subject: Re: one-to-many using link table???
PostPosted: Fri May 22, 2009 8:25 am 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
The only reason I would introduce the extra complexity of a join table for a one-to-many is if the items in the many side were not aware of the items on the one side. I've used this pattern for things like addresses where an Address can be referred to from e.g. an Order as well as an Account. In that situation, you would not want to have mulitple FK's back to order and account tables. Instead, use a join table (well documented in the Hibernate manual) per association and the address table can be reused.

Make sense?

-Chris

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject: Re: one-to-many using link table???
PostPosted: Fri May 22, 2009 9:39 am 
Newbie

Joined: Tue May 05, 2009 6:59 am
Posts: 2
that makes sense a lot , thanx...


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.