org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

Hibernate JIRA | Rich Christy | 5 years ago
  1. 0

    2011-08-24 16:00:15,886 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275) at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:114) at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109) at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:244) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2242) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2678) at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028) at org.hibernate.envers.synchronization.AuditSync.beforeCompletion(AuditSync.java:161) at org.hibernate.transaction.JDBCTransaction.notifyLocalSynchsBeforeTransactionCompletion(JDBCTransaction.java:274) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:140) at org.openspaces.persistency.hibernate.DefaultHibernateExternalDataSource.executeBulk(DefaultHibernateExternalDataSource.java:107) at com.skyroad.motion.transactionmanager.util.TransactionMirrorExternalDataSource.executeBulk(TransactionMirrorExternalDataSource.java:32) What the code is doing in the exception handling of AuditSync.java (5th line from the bottom in the stack track) is rolling back the transaction as far as the hibernate session is concerned and then unconditionally throwing the exception to the next level. However, the code in notifyLocalSynchsBeforeTransactionCompletion() eating the exception so Gigaspaces isn't aware that it happened. This would explain why the database writes are rolled back but the space isn't. public void beforeCompletion() { if (workUnits.size() == 0 && undoQueue.size() == 0) { return; } try { // see: http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4178431 if (FlushMode.isManualFlushMode(session.getFlushMode()) || session.isClosed()) { Session temporarySession = null; try { temporarySession = session.getFactory().openTemporarySession(); executeInSession(temporarySession); temporarySession.flush(); } finally { if (temporarySession != null) { temporarySession.close(); } } } else { executeInSession(session); // Explicity flushing the session, as the auto-flush may have already happened. session.flush(); } } catch (RuntimeException e) { // Rolling back the transaction in case of any exceptions //noinspection finally try { if (session.getTransaction().isActive()) { session.getTransaction().rollback(); } } finally { //noinspection ThrowFromFinallyBlock throw e; } } } private void notifyLocalSynchsBeforeTransactionCompletion() { if (synchronizations!=null) { for ( int i=0; i<synchronizations.size(); i++ ) { Synchronization sync = (Synchronization) synchronizations.get(i); try { sync.beforeCompletion(); } catch (Throwable t) { log.error("exception calling user Synchronization", t); } } } }

    Hibernate JIRA | 5 years ago | Rich Christy
    org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
  2. 0

    2011-08-24 16:00:15,886 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275) at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:114) at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109) at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:244) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2242) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2678) at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79) at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263) at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167) at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50) at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028) at org.hibernate.envers.synchronization.AuditSync.beforeCompletion(AuditSync.java:161) at org.hibernate.transaction.JDBCTransaction.notifyLocalSynchsBeforeTransactionCompletion(JDBCTransaction.java:274) at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:140) at org.openspaces.persistency.hibernate.DefaultHibernateExternalDataSource.executeBulk(DefaultHibernateExternalDataSource.java:107) at com.skyroad.motion.transactionmanager.util.TransactionMirrorExternalDataSource.executeBulk(TransactionMirrorExternalDataSource.java:32) What the code is doing in the exception handling of AuditSync.java (5th line from the bottom in the stack track) is rolling back the transaction as far as the hibernate session is concerned and then unconditionally throwing the exception to the next level. However, the code in notifyLocalSynchsBeforeTransactionCompletion() eating the exception so Gigaspaces isn't aware that it happened. This would explain why the database writes are rolled back but the space isn't. public void beforeCompletion() { if (workUnits.size() == 0 && undoQueue.size() == 0) { return; } try { // see: http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4178431 if (FlushMode.isManualFlushMode(session.getFlushMode()) || session.isClosed()) { Session temporarySession = null; try { temporarySession = session.getFactory().openTemporarySession(); executeInSession(temporarySession); temporarySession.flush(); } finally { if (temporarySession != null) { temporarySession.close(); } } } else { executeInSession(session); // Explicity flushing the session, as the auto-flush may have already happened. session.flush(); } } catch (RuntimeException e) { // Rolling back the transaction in case of any exceptions //noinspection finally try { if (session.getTransaction().isActive()) { session.getTransaction().rollback(); } } finally { //noinspection ThrowFromFinallyBlock throw e; } } } private void notifyLocalSynchsBeforeTransactionCompletion() { if (synchronizations!=null) { for ( int i=0; i<synchronizations.size(); i++ ) { Synchronization sync = (Synchronization) synchronizations.get(i); try { sync.beforeCompletion(); } catch (Throwable t) { log.error("exception calling user Synchronization", t); } } } }

    Hibernate JIRA | 5 years ago | Rich Christy
    org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
  3. 0

    Hibernate Auto-Increment Setup

    Stack Overflow | 7 years ago | dharga
    org.hibernate.exception.SQLGrammarException: could not insert: [com.bob.proj.ws.model.MemberSelectedOption]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    org.hibernate.exception. SQLGrammarException [Solved] (Object Relational Mapping forum at Coderanch)

    coderanch.com | 9 months ago
    org.hibernate.exception.SQLGrammarException: could not insert: [com.entity.Joboy_tutorial]
  6. 0

    Eclispe + Hibernate + DB2 version 9

    Coderanch | 7 years ago | camilo lopes
    org.hibernate.exception.SQLGrammarException: could not insert: [br.com.bean.Pessoa]

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.exception.SQLGrammarException

      Could not execute JDBC batch update

      at org.hibernate.exception.SQLStateConverter.convert()
    2. Hibernate
      AbstractEntityPersister.insert
      1. org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
      2. org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
      3. org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
      4. org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:114)
      5. org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109)
      6. org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:244)
      7. org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2242)
      8. org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2678)
      8 frames
    3. Hibernate
      EntityInsertAction.execute
      1. org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
      1 frame
    4. Hibernate
      ActionQueue.executeActions
      1. org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
      2. org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
      3. org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
      3 frames
    5. Hibernate
      SessionImpl.flush
      1. org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
      2. org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
      3. org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
      3 frames
    6. A Hibernate O/RM Module
      AuditSync.beforeCompletion
      1. org.hibernate.envers.synchronization.AuditSync.beforeCompletion(AuditSync.java:161)
      1 frame
    7. Hibernate
      JDBCTransaction.commit
      1. org.hibernate.transaction.JDBCTransaction.notifyLocalSynchsBeforeTransactionCompletion(JDBCTransaction.java:274)
      2. org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:140)
      2 frames
    8. org.openspaces.persistency
      DefaultHibernateExternalDataSource.executeBulk
      1. org.openspaces.persistency.hibernate.DefaultHibernateExternalDataSource.executeBulk(DefaultHibernateExternalDataSource.java:107)
      1 frame
    9. com.skyroad.motion
      TransactionMirrorExternalDataSource.executeBulk
      1. com.skyroad.motion.transactionmanager.util.TransactionMirrorExternalDataSource.executeBulk(TransactionMirrorExternalDataSource.java:32)
      1 frame