0 Replies Latest reply on Jan 18, 2006 4:30 AM by Pieter-Jan Malfait

    Could not execute JDBC batch update [delete from .. on sele

    Pieter-Jan Malfait Newbie

      hi,

      i'm having a problem with jboss that crashes my database.


      this is exactly how i recreate it:

      i drop all tables having to do anything with my entity CommercieelContast, so they are all empty when i redeploy the app (the app creates all the table just fine). then i add 1 object to the table with my GUI, no errors and the data shows up in the database tables.
      then i do a simple hql query that selects all the objects for this entity :

      HQL = select from CommercieelContact


      i get this exception:

      2006-01-18 10:03:24,175 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session
      org.hibernate.exception.JDBCConnectionException: Could not execute JDBC batch update
       at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:72)
       at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:200)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:230)
       at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
       at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
       at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
       at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:877)
       at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:185)
       at org.jboss.ejb3.entity.ManagedEntityManagerFactory$SessionSynchronization.beforeCompletion(ManagedEntityManagerFactory.java:89)
       at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1473)
       at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1092)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:306)
       at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:162)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:74)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:32)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:189)
       at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
       at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:69)
       at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:566)
       at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:436)
       at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:239)
       at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:291)
       at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:168)
      Caused by: java.sql.BatchUpdateException: Batch entry 0 delete from CommercieelContact_Adres where CommercieelContact_id=6830 was aborted. Call getNextExce
       at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2396)
       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:340)
       at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2455)
       at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:484)
       at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
       at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:193)
       ... 32 more
      


      i'm wondering why jboss tries to do a delete on an empty table when i'm only doing a select ? is there something wrong with my HQL?

      i gather this exception indicates that jboss has lost connection to postgresql because it has crashed.

      2006-01-18 10:03:24,182 DEBUG [org.hibernate.util.JDBCExceptionReporter] could not log warnings
      org.postgresql.util.PSQLException: An I/O error occured while sending to the backend.
       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:201)
       at org.postgresql.jdbc2.AbstractJdbc2Connection.executeTransactionCommand(AbstractJdbc2Connection.java:625)
       at org.postgresql.jdbc2.AbstractJdbc2Connection.commit(AbstractJdbc2Connection.java:645)
       at org.postgresql.jdbc2.AbstractJdbc2Connection.setAutoCommit(AbstractJdbc2Connection.java:608)
       at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.checkTransaction(BaseWrapperManagedConnection.java:362)
       at org.jboss.resource.adapter.jdbc.WrappedConnection.checkTransaction(WrappedConnection.java:514)
       at org.jboss.resource.adapter.jdbc.WrappedConnection.getWarnings(WrappedConnection.java:400)
       at org.hibernate.util.JDBCExceptionReporter.logAndClearWarnings(JDBCExceptionReporter.java:22)
       at org.hibernate.jdbc.ConnectionManager.closeConnection(ConnectionManager.java:338)
       at org.hibernate.jdbc.ConnectionManager.cleanup(ConnectionManager.java:275)
       at org.hibernate.jdbc.ConnectionManager.close(ConnectionManager.java:207)
       at org.hibernate.impl.SessionImpl.close(SessionImpl.java:309)
       at org.hibernate.ejb.EntityManagerImpl.close(EntityManagerImpl.java:45)
       at org.jboss.ejb3.entity.ManagedEntityManagerFactory$SessionSynchronization.afterCompletion(ManagedEntityManagerFactory.java:104)
       at org.jboss.tm.TransactionImpl.doAfterCompletion(TransactionImpl.java:1508)
       at org.jboss.tm.TransactionImpl.completeTransaction(TransactionImpl.java:1180)
       at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:351)
       at org.jboss.aspects.tx.TxPolicy.endTransaction(TxPolicy.java:162)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:74)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:32)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:189)
       at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
       at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:69)
       at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:566)
       at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:436)
       at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:239)
       at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:291)
       at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:168)
      Caused by: java.io.IOException: Stream closed
       at sun.nio.cs.StreamEncoder.ensureOpen(StreamEncoder.java:38)
       at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:151)
       at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)
       at org.postgresql.core.PGStream.flush(PGStream.java:493)
       at org.postgresql.core.v3.QueryExecutorImpl.sendSync(QueryExecutorImpl.java:631)
       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:174)
       ... 38 more
      
      


      this is the postgres log when doing the query :

      LOG: statement: select omschrijvi0_.Taal_id as Taal1_2_, omschrijvi0_.omschrijvingen_id as omschrij2_2_, objectomsc1_.id as id12_0_, objectomsc1_.benaming
      LOG: statement: COMMIT
      LOG: could not send data to client: Connection reset by peer
      LOG: could not send data to client: Broken pipe
      LOG: statement: delete from CommercieelContact_Adres where CommercieelContact_id=$1
      


      this is how my classes are annotated related to the CommercieelContact to Adres relation :

      @OneToMany(cascade={CascadeType.ALL},fetch=FetchType.EAGER)
       public List<Adres> getLeverAdressen() {
       return leverAdressen;
       }
      
       public void setLeverAdressen(List<Adres> leverAdressen) {
       this.leverAdressen = leverAdressen;
       }


      please anyone has any idea on this ? please tell me it more info is needed. this is really a important problem because it stalls our development a lot ..

      also on a different matter :
      why do i get so much "done cascade ACTION_PERSIST_ON_FLUSH for collection" messages which indicate objects get repersisted, when doing a select? it seems it's quite unnecessary to do that..