This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
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.
Joined: May 31, 2006
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;
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.
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 ]
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?