-->
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: Hibernate call to Stored Procedure that does not return anyt
PostPosted: Wed May 07, 2008 6:35 pm 
Newbie

Joined: Wed May 07, 2008 6:21 pm
Posts: 6
Location: Lakewood, CO
Hi all,

I need to call an Oracle stored procedure. The proc does not return anything, It takes 4 input and updates some dates on tables.

I find examples of this but all have something like:
{ ? = call PRC_UNFIT_FILER(?,?,?,?) }

What syntax do I use if the proc does not return a value?

I am using Hibernate3.

My map file:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="edu.ndsu.table.data" default-cascade="save-update">

<sql-query name="ICC.PRC_UNFIT_FILER" callable="false">
{ ? = call PRC_UNFIT_FILER(?,?,?,?) }
</sql-query>
</hibernate-mapping>

I have no <return> set in the map, because I'm not sure what to do.

My Java code:
Session session = null;
session = HibernateUtil.getSession();

Query query = session.getNamedQuery("ICC.PRC_UNFIT_FILER");
query.setParameter(0, "12345");
query.setParameter(1, new Date());
query.setParameter(2, new Date());
query.setParameter(3, "UNINDSU"); int mylist = query.executeUpdate();

Of course, I;m not sure if executeUpdate() is correct either. Thsi code gets:
May 7, 2008 4:14:15 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: Missing IN or OUT parameter at index:: 5
org.hibernate.exception.GenericJDBCException: could not execute native bulk manipulation query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:174)
at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1163)
at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:334)
at edu.ndsu.uniface.test.UnifaceAccessorTest.main(UnifaceAccessorTest.java:68)
Caused by: java.sql.SQLException: Missing IN or OUT parameter at index:: 5
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:1681)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3280)
....

And last, the Oracle proc:
REATE OR REPLACE PROCEDURE ICC.PRC_UNFIT_FILER (p_inser_id in VARCHAR2, p_trans_date in DATE, p_eff_date in DATE,p_reg_username in VARCHAR2) as
BEGIN
<<main>>
DECLARE
w_inser_id VARCHAR2(5) := 'begin';
w_eff_date DATE;
... lots of SQL code

end;

Thanks, I appreciate any help.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 08, 2008 11:23 am 
Newbie

Joined: Wed Aug 01, 2007 10:36 am
Posts: 7
daniel, look my topic,
[url]
http://forum.hibernate.org/viewtopic.php?t=986610
[/url]

for me works fine with in parameters, but i have problems with the return parameters of the stored procedure.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 08, 2008 1:12 pm 
Newbie

Joined: Wed May 07, 2008 6:21 pm
Posts: 6
Location: Lakewood, CO
Wait success!
I changed { ? = call PRC_UNFIT_FILER(?,?,?,?) } to
{ call PRC_UNFIT_FILER(?,?,?,?) } and the call now works. I saw in your mapping that you did not have the leading"?" in you <sql-query>.

I think I had that syntax before, so maybe I changed something else in all of my messing around.

Thanks


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.