-->
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: Named Query Not Returning Correct Results
PostPosted: Sun Mar 12, 2006 7:36 pm 
Beginner
Beginner

Joined: Wed Mar 01, 2006 11:26 pm
Posts: 23
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]


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.