• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Executing procedure in Hibernet with more than one out parameters

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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;
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Will Way
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??.......
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic