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.  [ 1 post ] 
Author Message
 Post subject: one-to-many query returns three rows but collection size=1
PostPosted: Wed Feb 21, 2007 4:44 pm 
Newbie

Joined: Wed Feb 21, 2007 2:20 pm
Posts: 2
Hibernate version:
3.0

Mapping documents:
<?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>

<class name="com.allstate.pega.test.SourceParty" table="KFTCL">

<composite-id name="clientId" class="com.allstate.pega.test.SourcePartyPk">
<key-property name="clientId" column="CLIENT_ID1" type="int"/>
<key-property name="clientId2" column="CLIENT_ID2" type="int"/>
</composite-id>

<set name="partyPerson" inverse="true" outer-join="true" cascade="all">
<key>
<column name="CLIENT_ID1"/>
<column name="CLIENT_ID2"/>
</key>
<one-to-many class="com.allstate.pega.test.PartyPerson"/>
</set>

</class>

<class name="com.allstate.pega.test.PartyPerson" table="KFTCPAR">

<composite-id name="clientId" class="com.allstate.pega.test.PartyPersonPk">
<key-property name="clientId" column="CLIENT_ID1" type="int" />
<key-property name="clientId2" column="CLIENT_ID2" type="int"/>
</composite-id>

<many-to-one name="sourceParty" class="com.allstate.pega.test.SourceParty" update="false" insert="false" not-null="true" fetch="join" lazy="false">
<column name="CLIENT_ID1"/>
<column name="CLIENT_ID2"/>
</many-to-one>

<property name="policyId" column="POLICY_ID1" type="int"/>
<property name="policyId2" column="POLICY_ID2" type="int"/>

</class>

</hibernate-mapping>


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

SourcePartyPk pk = new SourcePartyPk();
pk.setClientId(new Integer(358481700));
pk.setClientId2(new Integer(81));
SourceParty l = (SourceParty)service.load(com.allstate.pega.test.SourceParty.class, pk);

for(Iterator it = l.getPartyPerson().iterator(); it.hasNext();){
PartyPerson pp =(PartyPerson)it.next();
System.err.println("-->"+pp.getPolicyId() + ":" + pp.getPolicyId2());
}


Full stack trace of any exception that occurs:

none

Name and version of the database you are using:

Oracle 10g

The generated SQL (show_sql=true):

select sourcepart0_.CLIENT_ID1 as CLIENT1_4_1_, sourcepart0_.CLIENT_ID2 as CLIENT2_4_1_, partyperso1_.CLIENT_ID1 as CLIENT1_3_, partyperso1_.CLIENT_ID2 as CLIENT2_3_, partyperso1_.CLIENT_ID1 as CLIENT1_5_0_, partyperso1_.CLIENT_ID2 as CLIENT2_5_0_, partyperso1_.POLICY_ID1 as POLICY3_5_0_, partyperso1_.POLICY_ID2 as POLICY4_5_0_ from TEST.KFTCL sourcepart0_ left outer join TEST.KFTCPAR partyperso1_ on sourcepart0_.CLIENT_ID1=partyperso1_.CLIENT_ID1 and sourcepart0_.CLIENT_ID2=partyperso1_.CLIENT_ID2 where sourcepart0_.CLIENT_ID1=? and sourcepart0_.CLIENT_ID2=?

Debug level Hibernate log excerpt:

-----------------------------------------------------------------------------------

the generated SQL returns three rows, but my one-to-many collection only has 1 object


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.