-->
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.  [ 4 posts ] 
Author Message
 Post subject: Issue loading collection with fetch = join
PostPosted: Tue May 17, 2005 2:54 am 
Newbie

Joined: Mon May 16, 2005 5:27 am
Posts: 5
Loading a parent-childs relationship mapped with a collection I'm getting a list with several times the same parent - same pointer. Actually for each child I'm getting a 'new' parent.

The issue is for two large tables (1mio parents and over 20mio childs).

I would appreciate some help or ideas on this issue (currently join fetch is disabled).

ScrollableResult is not working for collection, bad luck as it was a good idea.

We had too disable secondary cache as it had some memory leaks - sorry no time to understand/find out why.

Mapping file :

<hibernate-mapping package="ch.iris.riskpro.tng.model.contract">
<class name="Contract_CFL">
<id name="contractID" column="CONTRACT_ID">
<generator class="increment"/>
</id>
<set name="cashflows" lazy="false" cascade="all-delete-orphan">
<key column="CONTRACT_ID"/>
<one-to-many class="ContractCashflow_CFL"/>
</set>
<property name="bookValueDate" type="timestamp" column="BOOK_VALUE_DATE"/>
<property name="contractDealDate" type="timestamp" column="CONTRACT_DEAL_DATE"/>
<property name="fxRateAtCDD" column="FX_RATE_AT_CCD"/>
<property name="fxRateAtBVD" column="FX_RATE_AT_BVD"/>
<property name="sourceSystemName" column="SOURCE_SYSTEM_NUMBER"/>
<many-to-one name="contractCurrency" class="ch.iris.riskpro.tng.model.market.Currency" lazy="false" column="CONTRACT_CURRENCY"/>
</class>

<class name="ContractCashflow_CFL" table="CONTRACT_CFL_CASHFLOW">
<id name="id" column="ID">
<generator class="increment"/>
</id>
<property name="amount" column="AMOUNT"/>
<property name="date" column="AMOUNT_DATE"/>
</class>
</hibernate-mapping>


Code :

Criteria criteria = session.createCriteria(Contract_CFL.class)
.setFetchMode("cashflows", FetchMode.JOIN);
List list = criteria.list();
iter = list.iterator();
listSize = list.size();


Result :

[0] = {ch.iris.riskpro.tng.model.contract.Contract_CFL@1822}
...
[8] = {ch.iris.riskpro.tng.model.contract.Contract_CFL@1822}
[9] = {ch.iris.riskpro.tng.model.contract.Contract_CFL@2033}
..
[17] = {ch.iris.riskpro.tng.model.contract.Contract_CFL@2033}


Top
 Profile  
 
 Post subject: Re: Issue loading collection with fetch = join
PostPosted: Wed Jun 08, 2005 10:07 am 
Newbie

Joined: Sat May 14, 2005 11:19 am
Posts: 14
Hello,

I have the same problem with Hibernate 3.0.5.

When I set the fetch mode to JOIN for a collection in a criteria query, hibernate does not eleminate the duplicates produced by the join. Instead Hibernate returns each object as many times as elements are in the collection belonging to this object. With fetch mode SELECT everything works fine, but I want eager fetching.

Is this a bug? Or have I missed something in the Hibernate book and online docs?

Markus


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 08, 2005 11:22 am 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
Run it through a distinct root result transformer. Think of it in the sense of what would happen in SQL if you tried the same thing, you would get a unique row for each combination.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 08, 2005 2:56 pm 
Newbie

Joined: Sat May 14, 2005 11:19 am
Posts: 14
Thanks for your answer.

I'm just too blind, because this topic is covered in the FAQ...

Markus


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