aspose file tools*
The moose likes Object Relational Mapping and the fly likes Executing procedure in Hibernet with more than one out parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Executing procedure in Hibernet with more than one out parameters" Watch "Executing procedure in Hibernet with more than one out parameters" New topic
Author

Executing procedure in Hibernet with more than one out parameters

Will Way
Greenhorn

Joined: May 31, 2006
Posts: 5
Hi,

Can anyone tell me how can i execute oracle stored procedure in Hibernet which has more than one out parameter.

I have been able to execute stored procedure which has one out parameter but the same method is not working with procedures containing more than one out parameter.

Please help.
Will Way
Greenhorn

Joined: May 31, 2006
Posts: 5
I am posting my procedure definition:-

create or replace PROCEDURE GetTestProc (p_test OUT SYS_REFCURSOR, p_test1 OUT SYS_REFCURSOR) as
BEGIN
OPEN p_test FOR
SELECT name as n1
FROM TEST ;
OPEN p_test1 FOR
SELECT name as n2
FROM TEST
WHERE PROJECT = 'ABC';
END;
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

In Hibernate you can only have one out parameter and it must be the first parameter. Right now, Hibernate does not support more than that.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Will Way
Greenhorn

Joined: May 31, 2006
Posts: 5
Hi,

Thanx for a quick reply. But are you sure,
Because, Hibernet 3.0 Docs says,

The first parameter of a procedure must be an OUT that returns a result set. This is done by using a SYS_REFCURSOR type in Oracle 9 or 10. In Oracle you need to define a REF CURSOR type, see Oracle literature.

No where in the docs they have mentioned that hibernet 3.0 doesn't support stored procedures with more than one out parameters.

What do you think??.......
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
Originally posted by Will Way:
No where in the docs they have mentioned that hibernet 3.0 doesn't support stored procedures with more than one out parameters.


It is my impression that hibernate treats a procedure with a single OUT parameter in the first position like a function where the return value is equivalent to that first parameter, while the second procedure parameter becomes the first function parameter, etc. Basically actually returning an OUT parameter in Java would require the use of "Holder" objects (which is actually done in Java Web Services) which is a level of complexity which Hibernate is attempting to avoid at this point. You may actually save yourself some grief by defining these "procedures" explicitly as functions. If you really need to "return" multiple parameters you may need to resort to storing those parameters/results in DB-session variables and access them subsequently through additional helper functions.
[ June 05, 2006: Message edited by: Peer Reynders ]

"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
Lazy Mojo
Greenhorn

Joined: Jul 28, 2009
Posts: 1
Hi Mark,
I'm a newbie to hibernate. I read your comments in the forum. Just wanted to know there is no other way by which hibernate handles a stored procedure which returns more than one output parameter?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Executing procedure in Hibernet with more than one out parameters
 
Similar Threads
pass a cursor between databases
Is hibernet an upcoming technology
HIBERNET
difference between ejb and hibernet
How Do You Configure Hibernate