-->
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: Many to Many
PostPosted: Sun Dec 07, 2008 5:19 pm 
Newbie

Joined: Sun Dec 07, 2008 5:06 pm
Posts: 1
Location: Denver
Hibernate version: 2.0.50727


I am new to NHibernate and am wondering how to map a Many to Many with additional columns.


I have a table StudentDailyActivity with columns
Id - the primary auto incrementing key
StudentId - a foreign key to the Student Table
ClassId - a foreign key to the Class Table
SchoolYearId - a foreign key to the SchoolYear Table
ActivityNotes - a text field
HomeworkNotes - a text field.


I am not sure how to represent this. I have my Student, Class and SchoolYear mappings done, and I know how to do this with a pure Many to Many mapping, but in this case I have the additional columns of ActivityNotes and HomeworkNotes.

I am looking for the StudentDailyActivities to be a collection of my C# Student object.

Would someone please help a newbie.

Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 08, 2008 5:32 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
In this case you have to map the association as a separate entity:

Student m:1 SchoolYear 1:n Class

and use many-to-one associations on student and class instead of the many-to-many.

_________________
--Wolfgang


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.