OpenEJB
  1. OpenEJB
  2. OPENEJB-1798

@GeneratedValue fails to work in some situations with OpenJPA

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.0.0
    • Component/s: None
    • Labels:
      None

      Activity

      Hide
      Romain Manni-Bucau added a comment -

      by default OpenJPA was using RegistryManagedRuntime and the implementation of org.apache.openjpa.ee.RegistryManagedRuntime#doNonTransactionalWork (which is invocated when OpenJPA tries to get the id value of an entity id annotated with @GeneratedValue) simply makes the operation fail. OpenJPA expects being able to suspend the transaction to go to the database to get it sequence id value but as the method throws an exception if doesn't work.

      using invocation(TransactionManagerMethod=org.apache.openejb.OpenEJB.getTransactionManager) for openjpa.ManagedRuntime makes it working.

      Show
      Romain Manni-Bucau added a comment - by default OpenJPA was using RegistryManagedRuntime and the implementation of org.apache.openjpa.ee.RegistryManagedRuntime#doNonTransactionalWork (which is invocated when OpenJPA tries to get the id value of an entity id annotated with @GeneratedValue) simply makes the operation fail. OpenJPA expects being able to suspend the transaction to go to the database to get it sequence id value but as the method throws an exception if doesn't work. using invocation(TransactionManagerMethod=org.apache.openejb.OpenEJB.getTransactionManager) for openjpa.ManagedRuntime makes it working.
      Hide
      Romain Manni-Bucau added a comment -

      here is the stack:

      org.apache.openjpa.ee.RegistryManagedRuntime.doNonTransactionalWork(RegistryManagedRuntime.java:203)
      at org.apache.openjpa.ee.AutomaticManagedRuntime.doNonTransactionalWork(AutomaticManagedRuntime.java:315)
      at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.allocateSequence(TableJDBCSeq.java:445)
      at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.nextInternal(TableJDBCSeq.java:300)
      at org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.next(AbstractJDBCSeq.java:60)
      at org.apache.openjpa.util.ImplHelper.generateValue(ImplHelper.java:160)
      at org.apache.openjpa.util.ImplHelper.generateFieldValue(ImplHelper.java:144)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignField(JDBCStoreManager.java:756)
      at org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:493)
      at org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:469)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignObjectId(JDBCStoreManager.java:740)
      at org.apache.openjpa.kernel.DelegatingStoreManager.assignObjectId(DelegatingStoreManager.java:135)
      at org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:612)
      at org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:2977)
      at org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:40)
      at org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:1054)
      at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2112)
      at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2072)
      at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1990)
      at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:527)
      at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:512)
      at org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare(TransactionImpl.java:413)
      at org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:262)
      at org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:252)
      at org.apache.openejb.core.transaction.JtaTransactionPolicy.completeTransaction(JtaTransactionPolicy.java:328)
      at org.apache.openejb.core.transaction.TxRequired.commit(TxRequired.java:75)
      at org.apache.openejb.core.transaction.EjbTransactionUtil.afterInvoke(EjbTransactionUtil.java:73)
      at org.apache.openejb.core.singleton.SingletonContainer._invoke(SingletonContainer.java:245)
      at org.apache.openejb.core.singleton.SingletonContainer.invoke(SingletonContainer.java:193)
      at org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:260)
      at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:240)
      at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:91)
      at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:284)

      Show
      Romain Manni-Bucau added a comment - here is the stack: org.apache.openjpa.ee.RegistryManagedRuntime.doNonTransactionalWork(RegistryManagedRuntime.java:203) at org.apache.openjpa.ee.AutomaticManagedRuntime.doNonTransactionalWork(AutomaticManagedRuntime.java:315) at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.allocateSequence(TableJDBCSeq.java:445) at org.apache.openjpa.jdbc.kernel.TableJDBCSeq.nextInternal(TableJDBCSeq.java:300) at org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.next(AbstractJDBCSeq.java:60) at org.apache.openjpa.util.ImplHelper.generateValue(ImplHelper.java:160) at org.apache.openjpa.util.ImplHelper.generateFieldValue(ImplHelper.java:144) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignField(JDBCStoreManager.java:756) at org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:493) at org.apache.openjpa.util.ApplicationIds.assign(ApplicationIds.java:469) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignObjectId(JDBCStoreManager.java:740) at org.apache.openjpa.kernel.DelegatingStoreManager.assignObjectId(DelegatingStoreManager.java:135) at org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java:612) at org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:2977) at org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:40) at org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:1054) at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2112) at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2072) at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1990) at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:527) at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:512) at org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare(TransactionImpl.java:413) at org.apache.geronimo.transaction.manager.TransactionImpl.commit(TransactionImpl.java:262) at org.apache.geronimo.transaction.manager.TransactionManagerImpl.commit(TransactionManagerImpl.java:252) at org.apache.openejb.core.transaction.JtaTransactionPolicy.completeTransaction(JtaTransactionPolicy.java:328) at org.apache.openejb.core.transaction.TxRequired.commit(TxRequired.java:75) at org.apache.openejb.core.transaction.EjbTransactionUtil.afterInvoke(EjbTransactionUtil.java:73) at org.apache.openejb.core.singleton.SingletonContainer._invoke(SingletonContainer.java:245) at org.apache.openejb.core.singleton.SingletonContainer.invoke(SingletonContainer.java:193) at org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:260) at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:240) at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:91) at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:284)
      Hide
      Romain Manni-Bucau added a comment -

      forgotten to precise this issue appeared in polling-web module of polling sample (trunk of openejb)

      Show
      Romain Manni-Bucau added a comment - forgotten to precise this issue appeared in polling-web module of polling sample (trunk of openejb)
      Hide
      David Blevins added a comment -
      Show
      David Blevins added a comment - 2012-03-15 - http://svn.apache.org/viewvc?view=revision&revision=1301191 - dblevins

        People

        • Assignee:
          Unassigned
          Reporter:
          David Blevins
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved:

            Development