-->
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.  [ 8 posts ] 
Author Message
 Post subject: Loading set of String Collection
PostPosted: Thu Nov 20, 2003 7:21 am 
When load the parent object, the child collection was always empty.

Following is the mapping file:

<class name="com.alfacom.loyalty.userMgt.model.CustomerDO"
table="userMgt_model_CustomerDO">

<composite-id unsaved-value="any">
<key-property name="icNo" column="icNo" type="string"/>
<key-property name="programId" column="programId" type="string" length="10"/>
</composite-id>

<set name="handphone" table="userMgt_model_CustomerDO_Handphone" lazy="false" outer-join="true">
<key>
<column name="icNo"/>
<column name="programId" length="10"/>
</key>
<element column="handphone" length="20" unique="true" type="string"/>
</set>

</class>


Is it because the parent class has composite key?


Top
  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 7:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
Is it because the parent class has composite key?


No, why should it be?


Please show me the SQL that is generated.

Also exactly what version of Hibernate is it? outer-join support for collections of values is recent.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 10:04 pm 
I am using Hibernate 2.1 beta 5

SQL Generated:

Hibernate: select customer0_.icNo as icNo, customer0_.programId as programId, customer0_.firstName as firstName, customer0_.middleName as middleName, customer0_.lastName as lastName, customer0_.nickName as nickName, customer0_.gender as gender, customer0_.birthdate as birthdate, customer0_.joinDate as joinDate, customer0_.updateDate as updateDate, customer0_.emailAddr as emailAddr, customer0_.race as race, customer0_.addr1 as addr1, customer0_.addr2 as addr2, customer0_.addr3 as addr3, customer0_.state as state, customer0_.postcode as postcode, customer0_.country as country, customer0_.city as city, customer0_.password as password, customer0_.userCanChangePassword as userCan21_, customer0_.changePasswordAtLogon as changeP22_, customer0_.expiryDate as expiryDate from userMgt_model_CustomerDO customer0_ where (icNo='902329-14-5555' )AND(programId='1' )

Hibernate: select usermgt_0_.number as number__, usermgt_0_.icNo as icNo__, usermgt_0_.programId as programId__ from userMgt_model_CustomerDO_Handphone usermgt_0_ where usermgt_0_.icNo=? and usermgt_0_.programId=?



The full mapping file is:

<hibernate-mapping>

<class name="com.alfacom.loyalty.userMgt.model.CustomerDO"
table="userMgt_model_CustomerDO">

<composite-id unsaved-value="any">
<key-property name="icNo" column="icNo" type="string"/>
<key-property name="programId" column="programId" type="string" length="10"/>
</composite-id>

<set name="handphone" table="userMgt_model_CustomerDO_Handphone" lazy="false" outer-join="true">
<key>
<column name="icNo"/>
<column name="programId" length="10"/>
</key>
<element column="number" length="20" unique="true" type="string"/>
</set>

<property name="firstName" column="firstName" type="string"/>
<property name="middleName" column="middleName" type="string"/>
<property name="lastName" column="lastName" type="string"/>
<property name="nickName" column="nickName" type="string"/>
<property name="gender" column="gender" type="string"/>
<property name="birthdate" column="birthdate" type="timestamp"/>
<property name="joinDate" column="joinDate" type="timestamp"/>
<property name="updateDate" column="updateDate" type="timestamp"/>
<property name="emailAddr" column="emailAddr" type="string"/>
<property name="race" column="race" type="string"/>

<property name="addr1" column="addr1" type="string"/>
<property name="addr2" column="addr2" type="string"/>
<property name="addr3" column="addr3" type="string"/>
<property name="state" column="state" type="string"/>
<property name="postcode" column="postcode" type="string"/>
<property name="country" column="country" type="string"/>
<property name="city" column="city" type="string"/>


<component class="com.alfacom.loyalty.userMgt.model.Password" name="password" insert="true" update="true">
<property column="password" name="password" type="string"/>
<property column="userCanChangePassword" name="userCanChangePassword" type="boolean"/>
<property column="changePasswordAtLogon" name="changePasswordAtLogon" type="boolean"/>
<property column="expiryDate" name="expiryDate" type="timestamp"/>
</component>
</class>

</hibernate-mapping>


Top
  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 10:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
So the SQL looks correct.


Please try 2.1 beta 6, since this is new functionality and beta5 was a buggy release.


Are you sure there is actually correct data in the table?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 10:27 pm 
Sorry, the hibernate I am using should be 2.1 beta 6 (but the logger display INFO Environment:432 - Hibernate 2.1 beta 5. ??)

I run the sql statement in MySql Console, it return the data from collection correctly.


Top
  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 10:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
alright ... well submit this to JIRA I suppose.


But make sure its a super trimmed-down main() method with just one persistent class.


I'm not very inclined to believe in this one, because I know its well covered by the test suite. But obscure bugs are always possible.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 11:29 pm 
I didn't override equals() and hashCode() method in parent class. That is the problem. :(


Top
  
 
 Post subject:
PostPosted: Thu Nov 20, 2003 11:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
yes. it is.


hehe.


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