Hi,
I have successfully managed to call a stored procedure from Hibernate that returns multiple rows. The problem I discovered however, is that I am getting multiple copies of the 1st row in the result set.
I do get the correct number of rows.
Calling the sp outside of hibernate returns the right number of rows and data.
Any ideas?
Many thanks.
Jadiyo
Hibernate version: 3.1.1
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 default-lazy="true" >
<class
name="PumaSelFndBmkIA"
>
<id
name="policyNo"
type="java.lang.String"
column="policy_no"
>
<generator class="assigned" />
</id>
<property
name="policySubnumber"
type="java.lang.String"
column="policy_subnumber"
not-null="false"
length="50"
>
</property>
<property
name="managedFundCode"
type="java.lang.String"
column="managed_fund_code"
not-null="false"
length="50"
>
</property>
<property
name="fundId"
type="int"
column="fund_id"
not-null="false"
length="10"
>
</property>
<property
name="priceMid"
type="java.math.BigDecimal"
column="price_mid"
not-null="false"
>
</property>
</class>
<sql-query name="puma_sel_fnd_bmk_ia" callable="true">
<return alias="svo2" class="PumaSelFndBmkIA">
<return-property name="policyNo" column="policy_no"/>
<return-property name="policySubnumber" column="policy_subnumber"/>
<return-property name="managedFundCode" column="managed_fund_code"/>
<return-property name="priceMid" column="price_mid"/>
<return-property name="fundId" column="fund_id"/>
</return>
{ call my_sp( :Benchmarks_Only, :Policy_No, :Policy_Subnumber) }
</sql-query>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Query query = session.getNamedQuery("my_sp");
query = query.setInteger("Benchmarks_Only", 2);
query = query.setString("Policy_No", "31128");
query = query.setString("Policy_Subnumber", "003");
List list = query.list();
session.flush();
session.close();
if (list != null) {
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
PumaSelFndBmkIA ia = (PumaSelFndBmkIA) iterator.next();
System.out.println("ia = " + ia);
}
} else {
System.out.println("list is null");
}
Name and version of the database you are using:
Sybase 12.5
|