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