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.  [ 5 posts ] 
Author Message
 Post subject: Join Tables
PostPosted: Tue Mar 14, 2006 2:21 pm 
Newbie

Joined: Tue Mar 14, 2006 1:09 pm
Posts: 3
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

I have a table class which have classId plus ids from 4 different tables,
I wanna know how I can make mapping for this.

Example table class have classId, profesorId, examId, classroomId

Class id have fields Professor professor, Classroom classroom, Exam exam,

Proffesor have set of classes, Classroom have set of classes, Exam have set of classes, and when I try to delete one class from Classroom it's only want
to assigned null to classroomId in table class

Anybody can give mi idea how to map this

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 14, 2006 11:31 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Code:
<class name="Class" ...>
  ...
  <many-to-one class="Professor" column="ProfId" .../>
...
</class>

<class name="Professor" ... >
  ...
  <set name="Classes" inverse="true" cascade="none"/>
    <key column="ClassId">
    <one-to-many class="Class/>
  </set>
  ...
</class>
If you've got a Professor with a loaded set of Class objects, removing an object from the set will set that Class object's ProfId column to null. Class objects have to be deleted independently.

Obviously, this applies equally to all your other classes.


Top
 Profile  
 
 Post subject: problems again
PostPosted: Thu Mar 16, 2006 9:59 am 
Newbie

Joined: Tue Mar 14, 2006 1:09 pm
Posts: 3
Thanks tenwit but with mapping like this if in table class have more profesors,
it will take just one register!
I dont know how to resolve it...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 10:13 am 
Newbie

Joined: Tue Mar 14, 2006 1:09 pm
Posts: 3
tenwit and what you think wnen you say delete separately?
Saludos


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 5:24 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
If you want a Professor to have many Classes, and a Class to have many Professors, obviously you many-to-many mappings instead of one-to-many/many-to-one. The same principles apply, though.

Can you rephrase your last question? I couldn't get the exact meaning.


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