Hi all,
I am trying to call a stored procedure via hibernate 3, and map the resultset.
I could find mapping examples in the the hibernate distribution , but it always map properties from an entity (a class with a defined mapping).
My pb is my stored proc is returning data from different tables, not only one. Do i need to define a special mapping for this result set or
is it enough to declare this mapping in the <sql-query> ?
Here is my example:
** a stored procedure "SPtest_StoredProc()" that take no parameters and returns 4 columns. The stored proc returns values from different tables.
** only one mapping file containing only :
<sql-query name="test_SP" callable="true">
<return alias="p" class="test.Query">
<return-property name="startDate" column="STARTDATE"/>
<return-property name="endDate" column="ENDDATE"/>
<return-property name="regionCode" column="REGIONCODE"/>
<return-property name="name" column="NAME"/>
</return>
{ ? = call SPtest_StoredProc() }
</sql-query>
** a java bean Query with the four fields. ( Query.java )
** to test I do :
Query q = session.getNamedQuery("test_SP");
List list = q.list();
My problem is that the mapping is not correct, or at least my configuration is not valid because hibernate returns an "Unknown entity" when parsing the mapping, on the Query.class. I think it cannot map my class Query.java to the resultset
Has anyone tried something similar ?
Thanks for your help!
Bruce.
Code between sessionFactory.openSession() and session.close():
Query q = session.getNamedQuery("test_SP");
List list = q.list();
Full stack trace of any exception that occurs:
org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: test.Query
Name and version of the database you are using:
SQL Server
|