-->
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: pls look at this problem
PostPosted: Tue Mar 22, 2005 11:18 am 
Newbie

Joined: Tue Mar 22, 2005 10:42 am
Posts: 2
Code:
table "projects"  -- m:n --> "contact"


ends up in

Code:
"projects" <-- m:n -- "rel_proj_contact" -- n:m --> "contact"


until this point there's no problem. Hibernate resolves all contacts which are assigned to the project.

The fourth table has a relation to "rel_proj_contact".

Code:
"relationtype" <-- n:1 -- "rel_proj_contact"


Relationtype is for example "projectManager".

The Problem is to resolve a object of type "project" with all associated "contact"-objects that have "relationtype"-objects associated.

DATASET

Code:
<dataset>
   <table name='PROJECTS'>
      <column>id</column>
         <row>
            <value>50</value>
         </row>
         <row>
            <value>51</value>
         </row>
     </column>
   </table>
   <table name='CONTACT'>
      <column>id</column>
         <row>
            <value>100</value>
         </row>
         <row>
            <value>101</value>
         </row>
     </column>
   </table>
   <table name='RELATIONTYPE'>
      <column>id</column>
         <row>
            <value>200</value>
         </row>
         <row>
            <value>201</value>
         </row>
         <row>
            <value>202</value>
         </row>
     </column>
   </table>
   <table name='REL_PROJECTS_CONTACT'>
      <column>projectid</column>
      <column>contactid</column>
      <column>relationid</column>
         <row>
            <value>50</value>
            <value>100</value>
            <value>200</value>
         </row>
         <row>
            <value>50</value>
            <value>101</value>
            <value>201</value>
         </row>
         <row>
            <value>51</value>
            <value>101</value>
            <value>202</value>
         </row>
     </column>
   </table>
</dataset>


Any suggestions how to write the *.hbm-files. Target is to resolve everything in a object of type "project". thx for any answers


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 27, 2005 5:09 am 
Senior
Senior

Joined: Sat Jul 17, 2004 5:16 pm
Posts: 143
When there is something for complicated than I base case m:n, you should probably not have a m:n, and instead a 1:n and a n:1, so you have 4 classes for 4 tables. Then all the relationships should work out quite nicely. Chris


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.