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: Getting only one record on one-to-many
PostPosted: Mon Nov 20, 2006 5:25 pm 
Newbie

Joined: Wed Oct 04, 2006 2:43 pm
Posts: 16
Location: Lexington, KY
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.x

Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.acs.gs.juror.bo.Participant" table="INFORMIX.VOTERS">
<id name="participantNumber" column="PART_NO">
</id>
<property name="firstName" column="FNAME"/>
<property name="lastName" column="LNAME"/>
<component name="address" class="com.acs.gs.juror.bo.Address">
<property name="street" column="ADDRESS" type="string"/>
<property name="city" type="string"/>
<property name="state" type="string" />
<property name="zip" type="string" />
</component>
<property name="birthdate" type="timestamp" column="DOB"/>
<property name="homePhone" column="h_phone"/>
<property name="taxId" column="SIN"/>
<property name="gender" column="SEX"/>
<set name="pools" inverse="true">
<key column="PART_NO"/>
<one-to-many class="com.acs.gs.juror.bo.PoolInfo"/>
</set>
<component name="status" class="com.acs.gs.juror.bo.SourceStatus">
<property name="code" column="STATUS" />
</component>
</class>
</hibernate-mapping>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.acs.gs.juror.bo.PoolInfo" table="INFORMIX.POOL">
<id name="participantNumber" column="PART_NO">
</id>
<property name="poolNumber" column="POOL_NO"/>
<property name="active" column="IS_ACTIVE"/>
<property name="firstName" column="fname"/>
<property name="lastName" column="lname"/>
<property name="city"/>
<property name="state"/>
<property name="zip"/>
<property name="dateDeferred" type="timestamp" column="DEF_DATE"/>
<property name="dateDisqualified" type="timestamp" column="DATE_DISQ"/>
<property name="dateExcused" type="timestamp" column="DATE_EXCUS"/>
<property name="dateOfBirth" type="timestamp" column="DOB"/>
<property name="dateNext" type="timestamp" column="NEXT_DATE"/>
<property name="dateReturn" type="timestamp" column="RET_DATE"/>
<property name="responded"/>
<property name="homePhone" column="H_PHONE"/>
<property name="workPhone" column="W_PHONE"/>
<property name="disqualifiedCode" column="DISQ_CODE"/>
<property name="excuseCode" column="EXC_CODE"/>
<property name="courtLocation" column="LOC_CODE"/>
<property name="numberAwol" column="NO_AWOL"/>
<property name="numberAttended" column="NO_ATTENDED"/>
<property name="numberFta" column="NO_FTA"/>
<property name="numberOfDeferralsPosted" column="NO_DEF_POS"/>
<property name="onCall" column="ON_CALL"/>
<property name="sequenceNumber" column="POOL_SEQ"/>
<many-to-one name="status"
column="STATUS"
class="com.acs.gs.juror.bo.PoolStatus"
fetch="join"
/>
</class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():

Using Spring

Full stack trace of any exception that occurs:

N/A

Name and version of the database you are using:

Informix 7.x

The generated SQL (show_sql=true):

Hibernate: select votersvo0_.part_no as part1_19_0_, votersvo0_.lname as lname19
_0_, votersvo0_.fname as fname19_0_, votersvo0_.address as address19_0_, votersv
o0_.city as city19_0_, votersvo0_.state as state19_0_, votersvo0_.zip as zip19_0
_, votersvo0_.h_phone as h8_19_0_, votersvo0_.dob as dob19_0_, votersvo0_.sex as
sex19_0_, votersvo0_.sin as sin19_0_, votersvo0_.date_selected1 as date12_19_0_
from voters votersvo0_ where votersvo0_.part_no=?

Debug level Hibernate log excerpt:
???

OK, my participant class has many PoolInfo instances just like the Voters as many Pool records. When I run the above query, I get only one PoolInfo class instead of the two that is in the database. Can anyone give me a guess as to why?

Thanks!


Top
 Profile  
 
 Post subject: There's two in the log
PostPosted: Mon Nov 20, 2006 6:21 pm 
Newbie

Joined: Wed Oct 04, 2006 2:43 pm
Posts: 16
Location: Lexington, KY
OK, I just sorted through the log and it turns out I got in the result set. Somehow, hibernate threw one away. Any ideas?

Thanks.


Top
 Profile  
 
 Post subject: Getting there
PostPosted: Mon Nov 20, 2006 8:51 pm 
Newbie

Joined: Wed Oct 04, 2006 2:43 pm
Posts: 16
Location: Lexington, KY
The problem appears to be that the key I specified to the Pool table is not unique. The key is multi-part and I only specified part_no so I could match it with my voters table. Evidently hibernate caches the answers to queries by the specified key, so when it got to the second record, it noticed the key was the same and quit. This is the problem.

Now to solve it!


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.