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: One to many collection with a link table
PostPosted: Thu Jun 12, 2008 8:03 am 
Newbie

Joined: Wed Jun 11, 2008 10:06 am
Posts: 6
I've tried to understand it by reading the documentation, but it is not written for the beginners, believe me!

So here is my question in the hope of finding a straight forward answer:

I have two classes: Car and Part.
Cars are stored in one table: Cars
Code:
TOYOTA
MAZDA


and Parts are stored in another table: Parts.
Code:
ENGINE
DOOR
WINDSCREEN
OILPUMP


Each entry in the table has a unique id and each car has multiple parts.

Now I have a third table to link these to. Lets call is Car_Parts
This table only has two columns: CarId and PartId. Here I link cars to their parts. For example:
Code:
TOYOTA, ENGINE
TOYOTA, DOOR
TOYOTA, WINDSCREEN
MAZDA, ENGINE
MAZDA, DOOR
MAZDA, OILPUMP


How can I use NHibernate for this structure?

Any help is very much appreciated.

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 13, 2008 2:31 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
This is a many-to-many collection. E.g., multiple cars have doors, cars have multiple parts.

This is mappable with NH; see http://www.hibernate.org/hib_docs/nhibe ... s-ofvalues


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.