-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem with external join
PostPosted: Thu Feb 19, 2004 7:20 am 
Newbie

Joined: Mon Sep 01, 2003 10:40 am
Posts: 17
I use Hibernate 2.0.3
I want make a one-to-many join with primary key and two column that aren't into primary key

Code:
table A
idNumber primary key
---------
date_end  column

table B
idNumber
idTabB
---------
date_end  column

class name="classA" table="A_RIFIUTI">
<composite-id name="id" class="PkclassA">
        <key-property name="idNumber" column="idNumber" >
      </composite-id>

       <set name="chid" table="B" inverse="true"  >
            <key>
                <column name="idNumber"/>
                <column name="date_end"/>  //this isn't into PK
            </key>
            <one-to-many class="classB"/>
        </set>
....


I want a sql code like :
Code:

select * from B where idNumber=? and date_end=?


and I want that hibernate set data_end parameter equal at data_end parent value
Is it correct my mappling ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2004 7:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
First of all, you don't really need a composite id for A if you have just one key-property.

Second, the key columns in the set must be the same as the id columns in the B class.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2004 8:11 am 
Newbie

Joined: Mon Sep 01, 2003 10:40 am
Posts: 17
Ok.
I tried also inser a where clause lihe this
Code:
where="tabA.date_end=tabB.date_end"

but Hibernate make a query like

Code:
_tableBalias.tabA.date_end=_tableBalias.tabB.date_end


Why a can't make a queru wth a external join ?


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