-->
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: Getting several times the same object with FetchMode = JOIN
PostPosted: Mon May 16, 2005 5:57 am 
Newbie

Joined: Mon May 16, 2005 5:27 am
Posts: 5
I'm getting several times the same object when setting Fetchmode equals to Join on a object parent-childs relationship. Actually, for each child I'm getting a 'new' parent - with the same pointer -.

Parent has a collection of child (no join table). Due to the large amount of data (>1mio Parents, 20mio Childs) don't fetching would be very time consuming as for each parent (more or less) we're doing a request to the database.

Scrollable results is not supported with collection on 3.0.3

If somebody has some idea how to solve, bypass this, I would appreciate :


Mapping :

<hibernate-mapping package="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 :

Load all data in packets of size bufferSize :

session.clear();
Criteria criteria = session.createCriteria(Contract_CFL.class)
.setFirstResult(firstResult)
.setMaxResults(firstResult+bufferSize)
.setFetchMode("cashflows", FetchMode.JOIN)
;
List list = criteria.list();
iter = list.iterator();
listSize = list.size();



I'm not sure if with this large amoung of data this is a good strategy (how efficient is setFirstResult()/setMaxResult() ?

When Run ...

currentResults: java.util.List = {java.util.ArrayList@2083} size = 50
[0] = {ch.iris.riskpro.tng.model.contract.Contract_CFL@2113}
[1] = {ch.iris.riskpro.tng.model.contract.Contract_CFL@2113}
[2] = {ch.iris.riskpro.tng.model.contract.Contract_CFL@2113}
....
[13] = {ch.iris.riskpro.tng.model.contract.Contract_CFL@2114}
[14] = {ch.iris.riskpro.tng.model.contract.Contract_CFL@2114}
[15] = {ch.iris.riskpro.tng.model.contract.Contract_CFL@2114}



The result is fine if I don't use Fetchmode.JOIN.

Cheers


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.