-->
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: Returning something from stored procedure and functions
PostPosted: Thu Sep 01, 2005 7:29 pm 
Beginner
Beginner

Joined: Tue Aug 30, 2005 2:33 am
Posts: 22
Database : Oracle 9.2

I have a question.

Say I have a procedure
Code:
create or replace procedure A(x OUT SYS_REFCURSOR) is
sr SYS_REFCURSOR;
begin
open sr for select id, name from person;
end;
/

mapping
Code:
<sql-query name="myQuery" callable="true">
<return-scalar column="id" type="long"/>
<return-scalar column="name" type="string"/>{call A(?)}
</sql-query>

How do I call from java, it gives me error
set
Query sel = s.getNamedQuery("myQuery");
sel.list();

[java] INFO - Checking 0 named queries
[java] DEBUG - opened session
[java] Actual Parameters: 0
[java] Named Parameters: 0
[java] org.hibernate.QueryException: Expected positional parameter count: 1
tual parameters: [] [
[java]
[java] {call A(?)}
[java] ]


How do we do the equivalent of
callableStatement.registerOutParameter(1, OracleTypes.CURSOR);

or could you suggest the way to execute the procedure whose out parameter is a ref cursor.

Moreover, can I safely assume Hibernate doesn't support calling of functions like this

Code:
create or replace function getn return number is
begin
return 2;
end;
/


If it does without changing the return 2 to

open mycur for select '2' as n from dual;
return mycur

then please let me know


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 01, 2005 11:30 pm 
Beginner
Beginner

Joined: Tue Aug 30, 2005 2:33 am
Posts: 22
I found the solution. I had a wrong hibernate3.jar.

weird.

1800 KB or 1636 KB both work with Stored Procedures
If the hibernate3.jar

3.1 1800KB
3.0.5 1636KB

before
3.0 won't work

I will write a short tutorial about getting started with hibernate for newbies shortly.
And will put a link here.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 4:45 am 
Newbie

Joined: Wed Sep 07, 2005 4:54 am
Posts: 4
sk08 wrote:
I found the solution. I had a wrong hibernate3.jar.

I will write a short tutorial about getting started with hibernate for newbies shortly.
And will put a link here.


That would be nice! thx!!!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 09, 2005 4:45 am 
Newbie

Joined: Wed Sep 07, 2005 4:54 am
Posts: 4
sk08 wrote:
I found the solution. I had a wrong hibernate3.jar.

I will write a short tutorial about getting started with hibernate for newbies shortly.
And will put a link here.


That would be nice! thx!!!


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.