I want to execute a simple Oracle stored procedure that does not require any parameters nor does it return any values or result sets. It just copies data between tables and all I need to do is execute it.
In straight SQL this is all I need to do:
EXECUTE MYSCHEMA.MY_PROCEDURE
In my DAO here's how I'm trying to get Hibernate to execute the procedure:
String sql = "EXECUTE MYSCHEMA.MY_PROCEDURE";
Query query = getCurrentSession().createSQLQuery(sql);
int result = query.executeUpdate();
But when I try this approach I get this error:
Code:
40903 [main] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 900, SQLState: 42000
40903 [main] ERROR org.hibernate.util.JDBCExceptionReporter - ORA-00900: invalid SQL statement
FAILED: testExtractTransfers
org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
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 us.or.state.doc.pre.data.PreaTransferDAO.extractNewTransfers(PreaTransferDAO.java:87)
at us.or.state.doc.pre.service.PreaWatchListServiceImpl.extractNewTransfers(PreaWatchListServiceImpl.java:145)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy39.extractNewTransfers(Unknown Source)
at us.state.or.doc.pre.service.PreaWatchListServiceImplTest.testExtractTransfers(PreaWatchListServiceImplTest.java:890)
at org.unitils.UnitilsTestNG.run(UnitilsTestNG.java:128)
Caused by: java.sql.SQLException: ORA-00900: invalid SQL statement
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:952)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1160)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3368)
at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:165)
... 45 more
... Removed 32 stack frames
Should I just get the Connection from the Hibernate session and write my own JDBC statement to execute the procedure?
Hibernate version: Hibernate 3
Name and version of the database you are using: Oracle 10g
Output from log SQL:
EXECUTE MYSCHEMA.MY_PROCEDURE