-->
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 with linking table
PostPosted: Wed Sep 07, 2005 1:48 pm 
Newbie

Joined: Thu Sep 01, 2005 3:55 pm
Posts: 11
I am trying to create a mapping file for a 1-* that has a linking/association table. The only way to do this seems to be with a many-to-many. So the mapping looks like this:

Code:
   <class name="OrderData" table="OrdOrder">

      <composite-id name="ID" class="InstanceID">
         <key-property name="ID" column ="OrderId" type ="Int32"/>
      </composite-id>
      
      <property name="ClientID" column="CustomerId" type="Int32" />

      <set name="Loans" table="OrdOrderLoan" >
         <key column="OrderId"/>
         <many-to-many column="LoanId" class="Loan"/>
      </set>
   </class>


The problem I have is with the collection. It is always empty even though I profile the sql and I see the child records retrieved. So I have two questions:
1. Is the mapping file correct?
2. Why don't the child entities get put into the collection?

Thanks,

_________________
~Dave Foderick


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 07, 2005 2:27 pm 
Newbie

Joined: Thu Sep 01, 2005 3:55 pm
Posts: 11
I failed to mention that the association table does not have a surrogate key. It has a composite primay key: OrderId+LoanId.

_________________
~Dave Foderick


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.