-->
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: pb mapping a stored procedure resultset
PostPosted: Tue Jun 21, 2005 4:26 am 
Newbie

Joined: Thu Jun 16, 2005 12:41 pm
Posts: 2
Location: Grenoble
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


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.