-->
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: hibernate mapping join key question
PostPosted: Thu May 25, 2006 1:41 pm 
Newbie

Joined: Thu Apr 06, 2006 6:06 pm
Posts: 10
Hibernate version: 3.0

Mapping documents:
Code:
<hibernate-mapping package="mats.valueObject">
   <class name="amts.valueObject.KodaacVO" table="TBL_KODAAC">
      <id name="id" type="long" column="SEQ_IND" >
         <generator class="sequence">
            <param name ="sequence">KODAAC_SEQ</param>
         </generator>
      </id>
   
      <property name="kodaac" type="java.lang.String" column="KODAAC" length="6"/>
      <property name="building" type="java.lang.String" column="BUILDING" length="6"/>
      <property name="mic" type="java.lang.String" column="MIC" length="3"/>
      <join table="TBL_BUILDING" inverse="false">
         <key column="building"/>
            <property name="staging" type="yes_no" column="IS_STAGING" length="1" />
            <property name="depacked" type="yes_no" column="DEPACK" length="1" />
    </join>
   </class>
</hibernate-mapping>


Name and version of the database you are using: Oracle 9i

The generated SQL (show_sql=true):
Code:
SELECT this_.seq_ind AS seq1_0_, this_.kodaac AS kodaac3_0_,
       this_.building AS building3_0_, this_.mic AS mic3_0_,
       this_1_.is_staging AS is2_4_0_, this_1_.depack AS depack4_0_
  FROM mill.tbl_kodaac this_ INNER JOIN mill.tbl_building this_1_ ON this_.seq_ind =
                                                                       this_1_.building
WHERE this_.active = 'Y'

This is what I want...note the change is that instead of using the id (seq_ind) of
KodaacVO I want to use one of the columns (the building column):
Code:
SELECT this_.seq_ind AS seq1_0_, this_.kodaac AS kodaac3_0_,
       this_.building AS building3_0_, this_.mic AS mic3_0_,
       this_1_.is_staging AS is2_4_0_, this_1_.depack AS depack4_0_
  FROM mill.tbl_dodaac this_ INNER JOIN mill.tbl_building this_1_ ON this_.building =
                                                                       this_1_.building
WHERE this_.active = 'Y'


Is this possible to do? Any suggestions. Should I be using something other than a join?
thanks for all help,
Nate


Top
 Profile  
 
 Post subject: clarifying
PostPosted: Thu May 25, 2006 1:45 pm 
Newbie

Joined: Thu Apr 06, 2006 6:06 pm
Posts: 10
I guess I wasn't really clear about my question.
I have two tables Kodaac and Building I'm trying to join two columns from the building table into the Kodaac Object. The association between the tables is on the building name which is unique, but is not a PK.

PS. From what I understan property-ref should allow me to do what I'm trying to do, but nothing seems to happen when i include it in the xml? Is it a broken feature?


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.