-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate stored procedure Ref Cursor as the last parameter
PostPosted: Fri Jan 30, 2009 12:59 am 
Newbie

Joined: Tue Jan 27, 2009 4:58 pm
Posts: 5
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.3.1.GA
Name and version of the database you are using:
Oracle 9i


Does anyone have a method to deal with cases where Ref Cursor is the last parameter? For example:

PROCEDURE GetUserAccountSP ( p_userId IN VARCHAR2,
cur_ACCOUNTS OUT T_CURSOR)
IS
BEGIN
OPEN cur_ACCOUNTS FOR
SELECT * FROM ACCOUNTS
WHERE user_id = p_userId;
END GetUserAccountSP ;

I have quite a few of these stored procedure and am having some trouble with the hibernate mapping since the first parameter in the mapping

{ call MYPKG.GetUserAccountSP (?, :userId) }

is reserved as an output parameter which will not work for me. If some one has a solution to this please let me know.

Thank you in advance
Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 01, 2009 1:31 pm 
Newbie

Joined: Tue Jan 27, 2009 4:58 pm
Posts: 5
I assume I will need to create a custom persister? Can someone at least guide me in the right direction?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 01, 2009 2:03 pm 
Senior
Senior

Joined: Thu Jan 08, 2009 3:48 pm
Posts: 168
I know its not the cleanest solution but you could try write a wrapping function that has the return param at the first position.

Code:
PROCEDURE GetUserAccountSPHib (cur_ACCOUNTS OUT T_CURSOR, p_userId IN VARCHAR2)
IS
BEGIN
GetUserAccountSP(p_userId, cur_ACCOUNTS);
END GetUserAccountSP;


Also, i hope that was only a simplified example and not real code because thats what queries are for in Hibernate
Code:
createQuery("from Account a where a.userId = :userId")

etc


Top
 Profile  
 
 Post subject:
PostPosted: Sun Feb 01, 2009 2:36 pm 
Newbie

Joined: Tue Jan 27, 2009 4:58 pm
Posts: 5
Thanks pkleindl, I started down that road but there are too many stored procedures and they are quite complex. This may become a maintenance issue so I was looking for something a little cleaner.
Yes, this is definitely a simple example and by no means an actual stored procedure.
I am attempting to write a custom persister but find myself overriding too many methods for such a simple task.
Any other suggestions will be deeply appreciated.


Top
 Profile  
 
 Post subject: Re: Hibernate stored procedure Ref Cursor as the last parameter
PostPosted: Fri Jun 12, 2009 10:40 am 
Newbie

Joined: Tue Jan 27, 2009 4:58 pm
Posts: 5
Any other suggestions to making the ref cursor the last parameter vs the first. I am working on a project where there are over 200 stored procedures and it will be very tedious to create wrappers for all of these stored procedures.

Thank you in advance.


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