-->
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.  [ 2 posts ] 
Author Message
 Post subject: Stored Prodcedure returns same item in resultset
PostPosted: Mon May 22, 2006 7:00 am 
Newbie

Joined: Mon May 22, 2006 6:35 am
Posts: 3
Hi,

I'm trying to get results from a stored procedure.
Everything works fine, except for 1 thing:
The resultset gives the correct number of results but the items in the resultset are all the same (first element of resultset).

Can anyone help me here?



Hibernate version: version 3.1.3, March 20, 2006

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 package="be.cs.fashion.awg.model.relatie">
<class name="OpenstaandePosten" table="SOAJAVA.OPENPOST">

<composite-id name="id" class="OpenstaandePostenID">
<key-property name="firm90" column = "FIRM90"/>
</composite-id>
<property name="sbrk90" column = "SBRK90"/>
<property name="stkd90" column = "STKD90"/>
<property name="rfnr90" column = "RFNR90"/>
<property name="stdt90" column = "STDT90"/>
<property name="bdrg90" column = "BDRG90"/>
<property name="krt190" column = "KRT190"/>
<property name="vvdt90" column = "VVDT90"/>
<property name="bdr290" column = "BDR290"/>
<property name="std290" column = "STD290"/>
<property name="bdr390" column = "BDR390"/>
<property name="bdr490" column = "BDR490"/>
<property name="bdr590" column = "BDR590"/>
</class>



<sql-query name="selectOpenstaandenPosten" callable="true">
<return alias="emp" class="OpenstaandePosten">
<return-property name="firm90" column = "FIRM90"/>
<return-property name="sbrk90" column = "SBRK90"/>
<return-property name="stkd90" column = "STKD90"/>
<return-property name="rfnr90" column = "RFNR90"/>
<return-property name="stdt90" column = "STDT90"/>
<return-property name="bdrg90" column = "BDRG90"/>
<return-property name="krt190" column = "KRT190"/>
<return-property name="vvdt90" column = "VVDT90"/>
<return-property name="bdr290" column = "BDR290"/>
<return-property name="std290" column = "STD290"/>
<return-property name="bdr390" column = "BDR390"/>
<return-property name="bdr490" column = "BDR490"/>
<return-property name="bdr590" column = "BDR590"/>
</return>
{ call slrelopost(:frmnbb,:hkkdbb,:rlnrbb) }
</sql-query>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Query query = session.getNamedQuery(storedProcID);
// Voor openstaande posten firma, herkomst en relatienummer
// { call slrelopost(:frmnbb,:hkkdbb,:rlnrbb) }
if (storedProcID.equals(SP_SELECT_OPENSTAANDE_POSTEN)){
query.setString("frmnbb", zoekCriteria.getNaam());
query.setString("hkkdbb", zoekCriteria.getHerkomst());
query.setString("rlnrbb", zoekCriteria.getRelatieNummer());
}
result = query.list();
for (Iterator iterator = result .iterator(); iterator.hasNext();){
Object item = iterator.next();
if(item instanceof OpenstaandePosten) {
OpenstaandePosten OPitem = (OpenstaandePosten) item;
//Set an extra item to an SWT table
setTableItem(OPitem, tblSearchResult, SWT.NONE);
}
}



Name and version of the database you are using:
DB400 iSeries 5.3


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 5:46 am 
Newbie

Joined: Mon May 22, 2006 6:35 am
Posts: 3
Problem solved:

the mapped id is not unique, even worse, for each row the value of the id is the same. So hibernate sees 12 times the same instance, resulting in hibernate taking 12 times the same instance from the cache.

Solution: map a truely unique id.


Sorry for the stupid question, it was to obvious but mostly we search to far for an explanation.

Greetz,
Pjotr


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