-->
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.  [ 3 posts ] 
Author Message
 Post subject: Why Hibernate with store procedure can't use OUT TYPES.curso
PostPosted: Mon Nov 28, 2005 10:26 am 
Newbie

Joined: Mon Nov 28, 2005 10:12 am
Posts: 2
[b]Hibernate version:[3.0.5]

Why Hibernate with store procedure can't use with this procedure style.

I

CREATE OR REPLACE PROCEDURE "TMP_XXXX#SEARCH"

(

result_cursor OUT TYPES.cursor_type
)
AS

BEGIN
OPEN result_cursor FOR
SELECT tbl_XXX.id,
tbl_XXX.col_1,
tbl_XXX.col_2,
tbl_XXX.col_3,
tbl_XXX.col_4



FROM tbl_XXX;


END;
/


------------
ERROR--

org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:112)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1414)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:153)
at
Caused by: java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'TMP_USP_RPT_RPT_S#SEARCH'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

......

<hibernate-mapping >

<class name="TBLXXX" table="TBL_XXX">

<id name="id" column="ID">
<generator class="native"/>
</id>

<property name="COL_1" column="COL_1"/>
<property name="COL_2" column="COL_2"/>
<property name="COL_3" column="COL_3"/>
<property name="COL_4" column="COL_4"/>


</class>

<sql-query name="selectAllXXX_SP" callable="true">
<return class="TBLXXX" >
<return-property name="id" column="ID"/>
<return-property name="COL_1" column="COL_1"/>
<return-property name="COL_2" column="COL_2"/>
<return-property name="COL_3" column="COL_3"/>
<return-property name="COL_4" column="COL_4"/>
</return>

{ ? = call TMP_XXXX#SEARCH() }
</sql-query>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 12:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
because it is not implemented. as stated in the docs the resultset must be *returned*.

In any case you can probably make it work by providing the proper binding in the Dialect.registerResultsetOutParameter()

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 10:44 pm 
Newbie

Joined: Mon Nov 28, 2005 10:12 am
Posts: 2
I try to fill parameter name same this.

<sql-query name="selectAllXXX_SP" callable="true">
<return class="TBLXXX" >
<return-property name="id" column="ID"/>
<return-property name="COL_1" column="COL_1"/>
<return-property name="COL_2" column="COL_2"/>
<return-property name="COL_3" column="COL_3"/>
<return-property name="COL_4" column="COL_4"/>
</return>

{ call TMP_XXXX#SEARCH(?,:param_in) } <--------
</sql-query>


i wonder it work!! I use normal org.hibernate.dialect.Oracle9Dialect


but if I try to pass parameter.


{ call TMP_XXXX#SEARCH(?,:param_in1,:param_in2) } <--------

and when hibernate check for parameters, it reverst form down to up for example.

CREATE OR REPLACE PROCEDURE "TMP_XXXX#SEARCH"

(

result_cursor OUT TYPES.cursor_type,
param_in1 IN tbl_xxx.col_1%TYPE,
param_in2 IN tbl_xxx.col_2%TYPE

)
AS

BEGIN
OPEN result_cursor FOR
SELECT tbl_XXX.id,
tbl_XXX.col_1,
tbl_XXX.col_2,
tbl_XXX.col_3,
tbl_XXX.col_4



FROM tbl_XXX

where tbl_XXX.col_1 = param_in1;
AND tbl_XXX.col_2 = param_in2



END;
/

---------

and then I call it.

Query q = session.getNamedQuery("selectAllXXX_SP");
q.setParameter("param_in1","xxxx"); // param index [1]
q.setParameter("param_in2","xxxx"); // param index [0]

List resultList = q.list();


and It work,

So, but I would like to change parameter index for
result_cursor OUT TYPES.cursor_type,

to param index [0].

Regards,
Suraphat Siri-upatham
Thailand.


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