org.hibernate.exception.SQLGrammarException: could not insert: [br.com.bean.Pessoa]

Coderanch | camilo lopes | 7 years ago
  1. 0

    Eclispe + Hibernate + DB2 version 9

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

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

    coderanch.com | 8 months ago
    org.hibernate.exception.SQLGrammarException: could not insert: [com.entity.Joboy_tutorial]
  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

    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
  6. 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

    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 insert: [br.com.bean.Pessoa]

      at org.hibernate.exception.SQLStateConverter.convert()
    2. Hibernate
      AbstractEntityPersister.insert
      1. org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
      2. org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
      3. org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2267)
      4. org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
      4 frames
    3. Hibernate
      EntityInsertAction.execute
      1. org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)
      1 frame
    4. Hibernate
      ActionQueue.executeActions
      1. org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
      2. org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
      3. org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
      3 frames
    5. Hibernate
      SessionImpl.managedFlush
      1. org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
      2. org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      3. org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
      4. org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
      4 frames
    6. Hibernate
      JDBCTransaction.commit
      1. org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
      1 frame
    7. br.com.dao
      PessoaDAO.salvar
      1. br.com.dao.PessoaDAO.salvar(PessoaDAO.java:22)
      1 frame
    8. br.com.controler
      PessoaControl.cadastrar
      1. br.com.controler.PessoaControl.cadastrar(PessoaControl.java:22)
      1 frame
    9. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      4. java.lang.reflect.Method.invoke(Unknown Source)
      4 frames
    10. Pax Jsp
      JspMethodExpression.invoke
      1. org.apache.el.parser.AstValue.invoke(AstValue.java:152)
      2. org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
      3. org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)
      3 frames
    11. JavaEE 7
      MethodBindingMethodExpressionAdapter.invoke
      1. javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
      1 frame
    12. JSF
      ActionListenerImpl.processAction
      1. com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
      1 frame
    13. JavaEE 7
      UIViewRoot.processApplication
      1. javax.faces.component.UICommand.broadcast(UICommand.java:383)
      2. javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
      3. javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
      3 frames
    14. JSF
      LifecycleImpl.execute
      1. com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
      2. com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
      3. com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
      3 frames
    15. JavaEE 7
      FacesServlet.service
      1. javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
      1 frame
    16. Glassfish Core
      CoyoteAdapter.service
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      3. org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      4. org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      5. org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      6. org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      7. org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      8. org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
      8 frames
    17. Grizzly HTTP
      JIoEndpoint$Worker.run
      1. org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      2. org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      3. org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      3 frames
    18. Java RT
      Thread.run
      1. java.lang.Thread.run(Unknown Source)
      1 frame