Is anyone able to perform an <sql-insert> using a stored procedure in PostrgeSQL 8.2? I am using Hibernate 3.2.3.GA and just about stumped.
1) With the following mapping definition:
Code:
<sql-insert callable="true" >
{call insert_data(cast(? as timestamp without time zone), cast(? as timestamp without time zone), cast(? as real), cast(? as real), ?, ?) }
</sql-insert>
On a session.flush() I am getting a
Quote:
A result was returned when none was expected.
exception. See end of this message for full stack trace.
2) When I try to add a parameter for a resultset as in the following mapping:
Code:
<sql-insert callable="true" >
{call [b]? =[/b] insert_data(cast(? as timestamp without time zone), cast(? as timestamp without time zone), cast(? as real), cast(? as real), ?, ?) }
</sql-insert>
The following error occurs:
Quote:
11:25:16,081 INFO [STDOUT] Hibernate: {call ? = insert_sensor_data(cast(? as timestamp without time zone), cast(? as timestamp without time zone), cast(? as real), cast(? as real), ?, ?) }
11:25:16,097 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: 22023
11:25:16,097 ERROR [JDBCExceptionReporter] No value specified for parameter 7.
11:25:16,097 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.DataException: Could not execute JDBC batch update
3) After days of searching and reading I found the following jira issue
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1745
That proposes a patch to add some callbacks
registerResultSetOutParameter() and
getResultSet().
This didn't seem to help. After tracing through the hibernate code I've found that the
QueryParameters passed to the
Loader class is returning false for the parameter's
isCallable() method. This prompts the loader to call the Batcher's
prepareQueryStatement() method and not the Batcher's
prepareCallableQueryStatement() method, and so, the callbacks added from the patch are never even called (hence error #2 above)
Like I said I am totally stumped at this point. Any help would be greatly appreciated.
Thank you for your time!
-Cary P
Full Stack Trace:
11:02:47,378 INFO [STDOUT] Hibernate: {call insert_data(cast(? as timestamp without time zone), cast(? as timestamp without time zone), cast(? as real), cast(? as real), ?, ?) }
11:02:47,394 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null
11:02:47,394 ERROR [JDBCExceptionReporter] Batch entry 0 select * from insert_data(cast(2007-04-18 18:02:47.331000 -0700 as timestamp without time zone), cast(2007-04-18 17:46:30.000000 -0700 as timestamp without time zone), cast(0.0 as real), cast(0.0 as real), 5, 94225) as result was aborted. Call getNextException to see the cause.
11:02:47,394 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: 0100E
11:02:47,394 ERROR [JDBCExceptionReporter] A result was returned when none was expected.
11:02:47,394 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: 0100E
11:02:47,394 ERROR [JDBCExceptionReporter] A result was returned when none was expected.
11:02:47,394 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: 0100E
11:02:47,394 ERROR [JDBCExceptionReporter] A result was returned when none was expected.
11:02:47,394 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: 0100E
11:02:47,394 ERROR [JDBCExceptionReporter] A result was returned when none was expected.
11:02:47,394 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: 0100E
11:02:47,394 ERROR [JDBCExceptionReporter] A result was returned when none was expected.
11:02:47,394 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: 0100E
11:02:47,394 ERROR [JDBCExceptionReporter] A result was returned when none was expected.
11:02:47,394 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: 0100E
11:02:47,394 ERROR [JDBCExceptionReporter] A result was returned when none was expected.
11:02:47,394 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: 0100E
11:02:47,394 ERROR [JDBCExceptionReporter] A result was returned when none was expected.
11:02:47,394 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update
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.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:253)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at com.ssi.listener.ejb.CListenerManagerBean.LogSensorData(CListenerManagerBean.java:822)
at sun.reflect.GeneratedMethodAccessor312.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:237)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:158)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:169)
at org.jboss.ws.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:64)
at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:63)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:121)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:136)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
at org.jboss.ejb.Container.invoke(Container.java:954)
at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:430)
at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:103)
at $Proxy55.LogSensorData(Unknown Source)
at com.ssi.listener.handler.CLogSensorData.process2(CLogSensorData.java:59)
at com.ssi.listener.handler.AHandler.process(AHandler.java:41)
at com.ssi.listener.servlet.CGetRequestType.doGet(CGetRequestType.java:78)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.sql.BatchUpdateException: Batch entry 0 select * from insert_sensor_data(cast(2007-04-18 18:02:47.331000 -0700 as timestamp without time zone), cast(2007-04-18 17:46:30.000000 -0700 as timestamp without time zone), cast(0.0 as real), cast(0.0 as real), 5, 94225) as result was aborted. Call getNextException to see the cause.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2530)
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleResultRows(AbstractJdbc2Statement.java:2494)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1258)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:350)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2592)
at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:517)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:246)
... 49 more