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: Stuck up with stored procedure using hibernate
PostPosted: Wed Apr 25, 2007 6:32 pm 
Beginner
Beginner

Joined: Thu Apr 15, 2004 2:01 pm
Posts: 25
Hello

I am using hibernate 3.0.5. I wrote a simple stored procedure which returns data from multiple tables. How can I get this data and how to do the mappings? I referred to documentation 16.2.2 but still not able solve the problem.

Procedure is as follows:

CREATE PROCEDURE selectEmpDepts (@id numeric(19,0))
RETURNS TABLE
AS
RETURN (SELECT EMP_Name, DEPT_ID FROM T_EMP e, T_EMP_DEPT d WHERE e.empId = d.empId)

I mentioned following in hbm.xml

<sql-query name="selectEmpDepts _SP" callable="true">
<return alias="ps" class="?????????????">
<return-property name="EMP_Name" column="EMP_NAME"/>
<return-property name="DEPT_ID" column="DEPT_ID"/>
</return>
{ ? = call selectEmpDepts (?) }

What should I mention in class attribute? Here this proc basically selects columns from different tables. and each class is mapped to each diff table.

I am using following stmt to run this code List lst = session.getNamedQuery("selectEmpDepts _SP").setInteger(1,3).list();

Is it correct way of doing it?

Appreaciate your help

Thank you


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.