Hi there
Im having a strange problem when trying to execute a Stored Procedure via a named query. The Stored procedure works correctly and returns the correct results from the tables and my hibernate code works correclty i.e. A List of results is returned from the Named Query. My problem is the results that are being returned...
The stored procedure returns the following results
+-----------------+----------+
| ParentFeeTypeID | RoleID |
+-----------------+----------+
| 6 | AGENT |
| 23 | AGENT |
| 3 | PO |
| 4 | PO |
| 5 | PO |
| 20 | PO |
| 21 | PO |
| 10 | PO |
| 1 | PCTFILER |
| 24 | PCTFILER |
+-----------------+----------+
I am trying to create a list of Role objects populated with the above data. However the List returns a set of classes akin to the following results
+-----------------+----------+
| ParentFeeTypeID | RoleID
+-----------------+----------+
| 6 | AGENT
| 6 | AGENT
| 3 | PO
| 3 | PO
| 3 | PO
| 3| PO
| 3| PO
| 3| PO
| 1 | PCTFILER
| 1 | PCTFILER
+-----------------+----------+
I.e The List contains the correct number of Role objects with the correct RoleIds however each individual Role class in the list is identical and is referenced in the same memory address. So the Agent roles are all identical as are the PO roles and the PCT Roles. I hope Im making sense here.
Does anyone have any idea whats going on here?
Any Help is greatly appreciated.
Chris
3.1.2
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse - Hibernate Tools --> <hibernate-mapping> <class name="com.pctfiler.fee.roles.Role" proxy="com.pctfiler.fee.roles.Role" lazy="true"> <id name="roleId" type="java.lang.String" />
<property name="sfAccountId" type="java.lang.Integer" /> <property name="feeType" type="java.lang.Integer" />
</class>
<sql-query name="Role" callable="true"> <return alias="roleId" class="com.pctfiler.fee.roles.Role"> <return-property name="role" column="f.RoleID" /> <return-property name="sfAccountId" column="f.SFAccountID" /> <return-property name="feeType" column="ft.ParentFeeTypeID" /> </return> { ? = CALL usp_get_suppliers(:ProductID, :CountryID) } </sql-query>
</hibernate-mapping>
query.setReadOnly(true); query.setParameter("ProductID", product.getId()); query.setParameter("CountryID", area.getId());
return query.list();
MySQL 5.0
[/code]
|