Hey there. We are trying to re-write an application using Hibernate/Spring/JSF. This is a legacy app where a majority of the logic resides inside of the database as stored procedures. As part of our application, we have a stored procedure that does some logging, system maintainance, and puts a row into a table. This stored procedure doesn't return a value. From reading the documentation, it's pretty clear that when calling a stored procedure you need to have the first variable in a stored procedure be an
OUT variable. I wrote a wrapper function around the stored procedure to return a sys_refcursor (via the hibernate docs). I am just assuming that the error that is getting thrown below is because I don't have a return value mapped.
When I was trying to call the original stored procedure without a return value I was getting what appeared to be 'off by one' errors (I would have two variables, would call setParameter(0,"a") and setParameter(1,"foo") and would receive the error "cannot set parameter:3").
My question is how do I map this return value? It's essentially a dummy value just to get this to work.. it doesn't map to a table or any type in our system. I've been haggling with this for two days now and don't see a concrete example of how to use it.
Thanks in advance!
Hibernate version:
3.2.0
Mapping documents:
Code:
<hibernate-mapping>
<sql-query name="send_message" callable="true">
{ call web_send_message(:entityId, :text, :deviceId) }
</sql-query>
<sql-query name="send_message_only" callable="true">
{ call medctr.op_send_message(:entityId, 'MEDICAL', :text, 'F', NULL, 'F', 'F', NULL, 'F', '1', 'F', 'F', 'F', :deviceId, 'F', NULL) }
</sql-query>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
getNamedQuery("send_message");
LOG.error("we are setting text");
query.setString("text", "this is a test page");
LOG.error("we are setting entityId");
query.setString("entityId", "6389")
.setString("deviceId", null)
/*LOG.error("we are setting pagerID");
query.setParameter("deviceId","123456")*/
.list();
}
catch (Exception e) {
LOG.error("we threw an exception",e);
}
Full stack trace of any exception that occurs:Code:
2007-01-19 08:52:15,894 DEBUG [org.hibernate.jdbc.AbstractBatcher] - <about to open PreparedStatement (open PreparedStatements: 0, globally: 0)>
2007-01-19 08:52:15,894 DEBUG [org.hibernate.jdbc.ConnectionManager] - <opening JDBC connection>
2007-01-19 08:52:15,941 DEBUG [org.hibernate.SQL] - <{ call web_send_message(?, ?, ?) }>
2007-01-19 08:52:15,941 DEBUG [org.hibernate.jdbc.AbstractBatcher] - <preparing statement>
2007-01-19 08:52:16,223 DEBUG [org.hibernate.loader.Loader] - <bindNamedParameters() this is a test page -> text [3]>
2007-01-19 08:52:16,223 DEBUG [org.hibernate.type.StringType] - <binding 'this is a test page' to parameter: 3>
2007-01-19 08:52:16,223 DEBUG [org.hibernate.loader.Loader] - <bindNamedParameters() null -> deviceId [4]>
2007-01-19 08:52:16,223 DEBUG [org.hibernate.type.StringType] - <binding null to parameter: 4>
2007-01-19 08:52:16,238 INFO [org.hibernate.type.StringType] - <could not bind value 'null' to parameter: 4; Invalid column index>
Name and version of the database you are using:
Oracle 10G