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.  [ 1 post ] 
Author Message
 Post subject: Mapping 1 Entity to 2 Tables Join Id Problem
PostPosted: Fri Nov 14, 2008 11:43 pm 
Newbie

Joined: Sat Oct 11, 2008 3:49 pm
Posts: 5
I have two tables that I want mapped to one entity. I just need one column from the second table. The problem is the <join> element will automatically use the id from the first table, but you can specify the id from the second. The column from the first table that joins the two tables isn't the id.

Is there a way to specify another column besides the id column to use from the first table?

Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="First" table="First">
      <id name="Id" column="First_Id" type="int">
         <generator class="assigned" />
      </id>
      <property name="Property1" column="Column1" />
      <property name="Property2" column="Column2" />
      <!--
      This is the column from table First that joins
      to table Second. How can I specify that I want
      to use Second_Id instead of First_Id to join
      the two tables together?
      <property name="SecondId" column="Second_Id" />
      -->
      <join table="Second">
         <key column="Second_Id" />
         <property name="Property3" column="Column3" />
      </join>
   </class>
</hibernate-mapping>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.