javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk update

Hibernate JIRA | Peter Lupo | 9 years ago
  1. 0

    When using Joined Subclass strategy, an entityManager.merge(detatchedSubclassInstance) on a subclass instance result in a query like this: insert into HT_TB_AMBIENTECONFIGURADO select ambienteco0_.ID as ID from TB_AMBIENTECONFIGURADO ambienteco0_ inner join TB_AMBIENTE ambienteco0_1_ on ambienteco0_.ID=ambienteco0_1_.ID where ID=33367 The "WHERE" condition is not using the table alias. The join is made on the same column, so it shouldn't matter from which table it would be get. Even then, Oracle complains with "ORA-00918: column ambiguously defined" as in the stacktrace included at the end of this description. The fix is presented by someone with the same problem on a MS SQL Server 2005 database here: http://forums.hibernate.org/viewtopic.php?t=969471 I have applied his fix and tested. It works correctly, generating a query with the table alias. The fixed class is attached with commentaries marking what has been changed (lines 374 to 383). javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk update at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:630) at org.hibernate.ejb.QueryImpl.executeUpdate(QueryImpl.java:59) at br.ufrj.cos.lens.taba.controle.gerencia.ambiente.CriaEntity.criaAmbConf(CriaEntity.java:36) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99) at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75) at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45) at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66) at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35) at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.hql.ast.exec.MultiTableUpdateExecutor.execute(MultiTableUpdateExecutor.java:127) at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:396) at org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:259) at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1141) at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:94) at org.hibernate.ejb.QueryImpl.executeUpdate(QueryImpl.java:50) ... 21 more Caused by: java.sql.SQLException: ORA-00918: column ambiguously defined at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145) 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:216) at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1120) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1279) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3415) at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3498) at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251) at org.hibernate.hql.ast.exec.MultiTableUpdateExecutor.execute(MultiTableUpdateExecutor.java:118) ... 26 more

    Hibernate JIRA | 9 years ago | Peter Lupo
    javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk update
  2. 0

    When using Joined Subclass strategy, an entityManager.merge(detatchedSubclassInstance) on a subclass instance result in a query like this: insert into HT_TB_AMBIENTECONFIGURADO select ambienteco0_.ID as ID from TB_AMBIENTECONFIGURADO ambienteco0_ inner join TB_AMBIENTE ambienteco0_1_ on ambienteco0_.ID=ambienteco0_1_.ID where ID=33367 The "WHERE" condition is not using the table alias. The join is made on the same column, so it shouldn't matter from which table it would be get. Even then, Oracle complains with "ORA-00918: column ambiguously defined" as in the stacktrace included at the end of this description. The fix is presented by someone with the same problem on a MS SQL Server 2005 database here: http://forums.hibernate.org/viewtopic.php?t=969471 I have applied his fix and tested. It works correctly, generating a query with the table alias. The fixed class is attached with commentaries marking what has been changed (lines 374 to 383). javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk update at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:630) at org.hibernate.ejb.QueryImpl.executeUpdate(QueryImpl.java:59) at br.ufrj.cos.lens.taba.controle.gerencia.ambiente.CriaEntity.criaAmbConf(CriaEntity.java:36) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99) at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75) at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45) at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66) at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35) at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk update at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.hql.ast.exec.MultiTableUpdateExecutor.execute(MultiTableUpdateExecutor.java:127) at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:396) at org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:259) at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1141) at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:94) at org.hibernate.ejb.QueryImpl.executeUpdate(QueryImpl.java:50) ... 21 more Caused by: java.sql.SQLException: ORA-00918: column ambiguously defined at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145) 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:216) at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1120) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1279) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3415) at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3498) at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251) at org.hibernate.hql.ast.exec.MultiTableUpdateExecutor.execute(MultiTableUpdateExecutor.java:118) ... 26 more

    Hibernate JIRA | 9 years ago | Peter Lupo
    javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk update
  3. 0

    SqlJmsProvider - Table or view does not exist

    Google Groups | 9 years ago | Raj
    java.sql.SQLException: ORA-00942: table or view does not exist
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    deleting profile

    Google Groups | 7 years ago | sanjayswain1
    java.sql.SQLException: ORA-02292: integrity constraint (COLEHAAN.FK08_DPS_USER) violated - child record found
  6. 0

    Hibernate Community • View topic - Fk referring to a composite id

    hibernate.org | 1 year ago
    javax.persistence.EntityExistsException: org.hibernate.exception.ConstraintViolationException: could not insert: [it.eng.cerssvd.datalayer.model.EBCharterer s]

    4 unregistered visitors
    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. java.sql.SQLException

      ORA-00918: column ambiguously defined

      at oracle.jdbc.driver.DatabaseError.throwSqlException()
    2. Oracle jdbc
      OraclePreparedStatement.executeUpdate
      1. oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
      2. oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
      3. oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
      4. oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
      5. oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
      6. oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1120)
      7. oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1279)
      8. oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3415)
      9. oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3498)
      9 frames
    3. JBoss Application Server Connector
      WrappedPreparedStatement.executeUpdate
      1. org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeUpdate(WrappedPreparedStatement.java:251)
      1 frame
    4. Hibernate
      MultiTableUpdateExecutor.execute
      1. org.hibernate.hql.ast.exec.MultiTableUpdateExecutor.execute(MultiTableUpdateExecutor.java:118)
      1 frame
    5. Hibernate HQL/JP-QL Parser
      QueryTranslatorImpl.executeUpdate
      1. org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:396)
      1 frame
    6. Hibernate
      QueryImpl.executeUpdate
      1. org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:259)
      2. org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1141)
      3. org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:94)
      3 frames
    7. Hibernate EJB
      QueryImpl.executeUpdate
      1. org.hibernate.ejb.QueryImpl.executeUpdate(QueryImpl.java:50)
      1 frame
    8. br.ufrj.cos
      CriaEntity.criaAmbConf
      1. br.ufrj.cos.lens.taba.controle.gerencia.ambiente.CriaEntity.criaAmbConf(CriaEntity.java:36)
      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. JUnit
      TestClassRunner.run
      1. org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
      2. org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
      3. org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
      4. org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
      5. org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
      6. org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
      7. org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
      8. org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
      9. org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
      10. org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
      10 frames
    11. JUnit4 Runner
      JUnit4TestReference.run
      1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
      1 frame
    12. JUnit3 Runner
      RemoteTestRunner.main
      1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      5 frames