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.  [ 2 posts ] 
Author Message
 Post subject: Using Stored Procedures
PostPosted: Fri Jan 11, 2008 6:05 am 
Newbie

Joined: Wed Feb 21, 2007 3:09 am
Posts: 16
Hi

I am using Hibernate 3.1.Trying to retrieve data from a stored Procedure.
My stored Procedure is

create procedure GET_DEPT_PROCEDURE(P_CURSOR OUT SYS_REFCURSOR,dno IN NUMBER)
BEGIN
open P_CURSOR for
select * from DEPT where deptno=dno;
END;

My hbm file contains the named query as

<sql-query name="DeptDetails" callable="true">
<return alias="DeptObj" class="storedProcs.DeptObj">

<return-property name="dname" column="DNAME"/>
<return-property name="location" column="LOC"/>
<return-property name="deptno" column="DEPTNO"/>
</return>
{ call GET_DEPT_PROCEDURE(?,:deptno) }
</sql-query>

I am using the following java code

s = getHibernateTemplate().getSessionFactory().openSession();
Query f = s.getNamedQuery("DeptDetails").setInteger("deptno",10);
f.list();

How can I set the first positional parameter.. Even though I donot set the value of the first parameter, I can run the prgm and get expected results.

I guess Hibernate takes care of setting this value.If so , I want to know the value of this parameter to be able to set that explcitly which is my requirement (in a different use case of course...).

Is there a method to register OUT params like we have in JDBC..

stmt.registerOutParam(.....)

Thanks in advance
Ramesh


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 29, 2009 1:24 am 
Newbie

Joined: Tue Jan 27, 2009 4:58 pm
Posts: 5
In addition to this question, is it possible to make REF CURSOR the last parameter? If so can someone post an example?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.