-->
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: Using Criteria query with composite-id columns
PostPosted: Mon Oct 16, 2006 10:44 am 
Newbie

Joined: Tue Feb 28, 2006 5:28 pm
Posts: 2
Hi
I am using Hibernate 3.1 and Weblogic 8. I have the following Hibernate Mappings

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping schema="HGAPPVRZ">

<class name="hibbertgroup.verizon.entity.NonCompCodes" table="VRZ_REBATE_NONCOMP_CODES">
<composite-id>
<key-property name="offerCode" column="OFFER_CODE" type="string" />
<key-property name="nonCompCode" column="NONCOMP_CODE" type="string"/>
</composite-id>
<property name="nonCompDesc" column="NONCOMP_CODE_DESC" type="string"/>
<property name="nonCompRMCDesc" column="NONCOMP_CODE_RMC_DESC" type="string"/>
<property name="nonCompCodeStatus" column="NONCOMP_STATUS" type="string"/>
</class>

</hibernate-mapping>


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping schema="HGAPPVRZ">

<class name="hibbertgroup.verizon.entity.DBNonComp" table="VRZ_REBATE_DB_NONCOMP">
<composite-id>
<key-property name="hibId" column="REBATE_HIB_ID" type="long" />
<key-property name="transSeq" column="TRANS_SEQ" type="integer"/>
<key-property name="nonCompCode" column="NONCOMP_CODE" type="string" />
</composite-id>
<many-to-one name="ncode" class="hibbertgroup.verizon.entity.NonCompCodes" update="false" insert="false" >
<column name="OFFER_CODE" />
<column name="NONCOMP_CODE" />
</many-to-one>
<property name="loadDate" column="LOAD_DATE" type="java.util.Date"/>
</class>

</hibernate-mapping>



Now, I am using the following Java code

Criteria dbNonCompCrit = sess.createCriteria(DBNonComp.class);
dbNonCompCrit.add(Expression.eq("hibId", new Long(hibid)));
dbNonCompCrit.addOrder(Order.asc("transSeq"));
Criteria nonCompCriteria = dbNonCompCrit.createCriteria("ncode");


The problem I am having is that hibernate executes the following query

select
this_.REBATE_HIB_ID as REBATE1_13_1_,
this_.TRANS_SEQ as TRANS2_13_1_,
this_.NONCOMP_CODE as NONCOMP3_13_1_,
this_.OFFER_CODE as OFFER4_13_1_,
this_.LOAD_DATE as LOAD5_13_1_,
noncompcod1_.NONCOMP_CODE as NONCOMP1_11_0_,
noncompcod1_.OFFER_CODE as OFFER2_11_0_,
noncompcod1_.NONCOMP_CODE_DESC as NONCOMP3_11_0_,
noncompcod1_.NONCOMP_CODE_RMC_DESC as NONCOMP4_11_0_,
noncompcod1_.NONCOMP_STATUS as NONCOMP5_11_0_
from
HGAPPVRZ.VRZ_REBATE_DB_NONCOMP this_, HGAPPVRZ.VRZ_REBATE_NONCOMP_CODES noncompcod1_
where
this_.NONCOMP_CODE=noncompcod1_.NONCOMP_CODE and
this_.OFFER_CODE=noncompcod1_.OFFER_CODE and this_.REBATE_HIB_ID=?
order by
this_.TRANS_SEQ asc



There is no OFFER_CODE for HGAPPVRZ.VRZ_REBATE_DB_NONCOMP table as well as no offerCode property for DBNonComp object


How can I fix this?


Thanks
Jay


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 11:53 am 
Newbie

Joined: Tue Feb 28, 2006 5:28 pm
Posts: 2
Can any one help me?


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.