-->
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.  [ 4 posts ] 
Author Message
 Post subject: Calling stored procedure thru named query
PostPosted: Tue Nov 07, 2006 8:52 am 
Newbie

Joined: Fri Oct 27, 2006 7:32 am
Posts: 9
Hi,

I am using Hibernate + Spring. I want to retrieve the records from DEPT table using stored procedure.

Here is the stored pro:

CREATE OR REPLACE PACKAGE types
AS
TYPE ref_cursor IS REF CURSOR;
END;

CREATE OR REPLACE PROCEDURE GET_DEPT_PROCEDURE (
P_DEPTS OUT types.ref_cursor
)
AS
BEGIN
OPEN P_DEPTS FOR
SELECT
deptno as Id,
dname as namekey,
loc as Datekey FROM dept ;
END ;

And in Hibernate Mapping file this is the named query tag...

<sql-query name="name3" callable="true">
<return alias="DeptObj" class="secondEx.DeptObj"/>
{ call GET_DEPT_PROCEDURE() }
</sql-query>

Where DEPTOBJ is the POJO corresponding to DEPT table..


And in Retrieve button Action performed I am calling the following method.....


public ArrayList getAllDeptDtls(){
return

(ArrayList)getHibernateTemplate().findByNamedQuery("name3");


}


When I run this, I am getting the following error:

There is a exception in Retrieve Method....Hibernate operation: could not execute query; invalid ResultSet access for SQL [{ call GET_DEPT_PROCEDURE() }];

nested exception is java.sql.SQLException: Invalid column index
31735 [AWT-EventQueue-0] WARN util.JDBCExceptionReporter - SQL Error: 17003, SQLState: null

31735 [AWT-EventQueue-0] ERROR util.JDBCExceptionReporter - Invalid column index...

Thanx in advance

_________________
Sujatha K


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 9:05 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
Hi,
did you look at this:

http://www.hibernate.org/hib_docs/v3/re ... procedures

and especially that quote

Quote:
Recommended call form is standard SQL92: { ? = call functionName(<parameters>) } or { ? = call procedureName(<parameters>}. Native call syntax is not supported.


Maybe this helps.

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 9:33 am 
Newbie

Joined: Fri Oct 27, 2006 7:32 am
Posts: 9
Hi,

Thanx for the reply.....

Now I tried with,

call GET_DEPT_PROCEDURE(rr SYS_REFCURSOR) and also

call GET_DEPT_PROCEDURE(rr types.ref_cursor)

... but getting the same error

_________________
Sujatha K


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 08, 2006 12:01 am 
Newbie

Joined: Fri Oct 27, 2006 7:32 am
Posts: 9
Hi,

Now its working.. I tried with

<sql-query name="name3" callable="true">
<return alias="DeptObj" class="secondEx.DeptObj">
<return-property name="deptno" column="DEPTNO"/>
<return-property name="dname" column="DNAME"/>
<return-property name="location" column="LOC"/>
</return>
{ call GET_DEPT_PROCEDURE(?) }
</sql-query>

Thanx a lot....

_________________
Sujatha K


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.