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.  [ 4 posts ] 
Author Message
 Post subject: Setting up a one to many - many to one relationship.
PostPosted: Tue Sep 18, 2007 1:56 pm 
Newbie

Joined: Fri Sep 14, 2007 8:51 pm
Posts: 12
Location: North Carolina
Hibernate version: 2.2

Looking for a place to get started on this one. I have three tables. People, Skills, and PeopleSkills. PeopleSkills is a table with a uniqueID, PeopleID, and a SkillID. So I figured I could:
Use a one to many relationship to get at the PeopleSkills table.... but then I need to do extra work to get at the name of the Skill (contained in the Skill table). So basically I need help, before I waste alot of time going down the wrong path.

What is the right way to set this up? any good examples on the web?

Sorry if this is a really newb question,
kellygreer1


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 18, 2007 3:47 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
Do you really need a PeopleSkill object, or is that just the collection table in a many-to-many relationship (see http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/collections.html#collections-ofvalues)? If PeopleSkills really is only a link, there is no need to make it a full-fledged object. However, if it does carry other information, then PeopleSkill can also carry a many-to-one relationship to Skill.

If you need to navigate from Skills back to People, you can also set up a "one-to-many-to-one" in the other direction.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 19, 2007 1:13 pm 
Newbie

Joined: Fri Sep 14, 2007 8:51 pm
Posts: 12
Location: North Carolina
OK. So I get the one-to-many and the many-to-one.
But I'm still missing something about the many-to-many thing.

Where is the middle table named?

Both the examples under many-to-many on this cheat sheet [1] only have one table named. Shouldn't you have to name 2 tables here? and 3 tables in total?

What am I missing?

[1] - http://ndpsoftware.com/HibernateMappingCheatSheet.html

Thanks for your patience.
kellygreer1


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 19, 2007 1:31 pm 
Newbie

Joined: Fri Sep 14, 2007 8:51 pm
Posts: 12
Location: North Carolina
ok. I think I get it after reading:
http://www.theserverside.net/tt/article ... NHibernate

The example of the Department x Professors example is very good.
Made sense.

Thanks group,
kellygreer1


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