3 Replies Latest reply on Apr 13, 2007 1:55 PM by fhh

    EJB3 Transaction with Oracle 10g XE

    Abhinav Nigam Newbie

      Hi All

      I have two CMP entities (EJB3) defined over two tables in Oracle 10g XE DB, namely User & UserDetails. UserDetails references User entity in One-to-one unidirection fashion.

      When I create a new User I have to insert a record using User entity & a corresponding record using the UserDetail.

      Since the first insert is not committed when the UserDetails entity tries to insert the record in the UserDetails table. The parent child relationship fails.

      Where should I define the DB isolation level?

      Thanks in advance.

      Regards
      Abhinav

        • 1. Re: EJB3 Transaction with Oracle 10g XE
          Abhinav Nigam Newbie

          This is the stack trace


          22:33:06,403 INFO [STDOUT] Hibernate: select hibernate_sequence.nextval from dual
          
          22:33:07,336 INFO [STDOUT] Hibernate: select hibernate_sequence.nextval from dual
          
          22:33:07,531 INFO [STDOUT] Hibernate: insert into tusr (USR_LGN_ID, USR_ROLE_ID, LST_LGN_TS, USR_ADD_INF, CRTD_TS, CRTD_USR, UPDT_TS, UPDT_USR, USR_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
          
          22:33:08,309 WARN [JDBCExceptionReporter] SQL Error: 2291, SQLState: 23000
          
          22:33:08,310 ERROR [JDBCExceptionReporter] ORA-02291: integrity constraint (ATSUSER.SYS_C004032) violated - parent key not found
          
          22:33:08,310 WARN [JDBCExceptionReporter] SQL Error: 2291, SQLState: 23000
          
          22:33:08,310 ERROR [JDBCExceptionReporter] ORA-02291: integrity constraint (ATSUSER.SYS_C004032) violated - parent key not found
          
          22:33:08,321 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
          
          org.hibernate.exception.ConstraintViolationException
          : Could not execute JDBC batch update
          
          at org.hibernate.exception.SQLStateConverter.convert(
          SQLStateConverter.java:71)
          
          at org.hibernate.exception.JDBCExceptionHelper.convert(
          JDBCExceptionHelper.java:43)
          
          at org.hibernate.jdbc.AbstractBatcher.executeBatch(
          AbstractBatcher.java:249)
          
          at org.hibernate.jdbc.AbstractBatcher.prepareStatement(
          AbstractBatcher.java:92)
          
          at org.hibernate.jdbc.AbstractBatcher.prepareStatement(
          AbstractBatcher.java:87)
          
          at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(
          AbstractBatcher.java:218)
          
          at org.hibernate.persister.entity.AbstractEntityPersister.insert(
          AbstractEntityPersister.java:2159)
          
          at org.hibernate.persister.entity.AbstractEntityPersister.insert(
          AbstractEntityPersister.java:2595)
          
          at org.hibernate.action.EntityInsertAction.execute(
          EntityInsertAction.java:51)
          
          at org.hibernate.engine.ActionQueue.execute(
          ActionQueue.java:248)
          
          at org.hibernate.engine.ActionQueue.executeActions(
          ActionQueue.java:232)
          
          at org.hibernate.engine.ActionQueue.executeActions(
          ActionQueue.java:139)
          
          at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(
          AbstractFlushingEventListener.java:298)
          
          at org.hibernate.event.def.DefaultFlushEventListener.onFlush(
          DefaultFlushEventListener.java:27)
          
          at org.hibernate.impl.SessionImpl.flush(
          SessionImpl.java:1000)
          
          at org.hibernate.impl.SessionImpl.managedFlush(
          SessionImpl.java:338)
          
          at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(
          AbstractEntityManagerImpl.java:515)
          
          at org.jboss.tm.TransactionImpl.doBeforeCompletion(
          TransactionImpl.java:1491)
          
          at org.jboss.tm.TransactionImpl.beforePrepare(
          TransactionImpl.java:1110)
          
          at org.jboss.tm.TransactionImpl.commit(
          TransactionImpl.java:324)
          
          at org.jboss.tm.TxManager.commit(
          TxManager.java:240)
          
          at org.jboss.aspects.tx.TxPolicy.endTransaction(
          TxPolicy.java:175)
          
          at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(
          TxPolicy.java:87)
          
          at org.jboss.aspects.tx.TxInterceptor$Required.invoke(
          TxInterceptor.java:191)
          
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
          MethodInvocation.java:101)
          
          at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(
          TxPropagationInterceptor.java:76)
          
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
          MethodInvocation.java:101)
          
          at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(
          StatelessInstanceInterceptor.java:62)
          
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
          MethodInvocation.java:101)
          
          at org.jboss.aspects.security.AuthenticationInterceptor.invoke(
          AuthenticationInterceptor.java:77)
          
          at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(
          Ejb3AuthenticationInterceptor.java:102)
          
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
          MethodInvocation.java:101)
          
          at org.jboss.ejb3.ENCPropagationInterceptor.invoke(
          ENCPropagationInterceptor.java:47)
          
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
          MethodInvocation.java:101)
          
          at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(
          AsynchronousInterceptor.java:106)
          
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
          MethodInvocation.java:101)
          
          at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(
          StatelessContainer.java:263)
          
          at org.jboss.aop.Dispatcher.invoke(
          Dispatcher.java:106)
          
          at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(
          AOPRemotingInvocationHandler.java:82)
          
          at org.jboss.remoting.ServerInvoker.invoke(
          ServerInvoker.java:828)
          
          at org.jboss.remoting.ServerInvoker.invoke(
          ServerInvoker.java:681)
          
          at org.jboss.remoting.transport.socket.ServerThread.processInvocation(
          ServerThread.java:358)
          
          at org.jboss.remoting.transport.socket.ServerThread.dorun(
          ServerThread.java:398)
          
          at org.jboss.remoting.transport.socket.ServerThread.run(
          ServerThread.java:239)
          
          Caused by:
          java.sql.BatchUpdateException: ORA-02291: integrity constraint (ATSUSER.SYS_C004032) violated - parent key not found
          
          at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(
          DatabaseError.java:343)
          
          at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(
          OraclePreparedStatement.java:10657)
          
          at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(
          WrappedStatement.java:519)
          
          at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(
          BatchingBatcher.java:48)
          
          at org.hibernate.jdbc.AbstractBatcher.executeBatch(
          AbstractBatcher.java:242)
          
          ... 41 more
          
          22:33:41,582 INFO [STDOUT] Hibernate: select hibernate_sequence.nextval from dual
          
          22:33:41,587 INFO [STDOUT] Hibernate: select hibernate_sequence.nextval from dual
          
          22:33:41,597 INFO [STDOUT] Hibernate: insert into tusr (USR_LGN_ID, USR_ROLE_ID, LST_LGN_TS, USR_ADD_INF, CRTD_TS, CRTD_USR, UPDT_TS, UPDT_USR, USR_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
          
          22:33:41,608 WARN [JDBCExceptionReporter] SQL Error: 2291, SQLState: 23000
          
          22:33:41,608 ERROR [JDBCExceptionReporter] ORA-02291: integrity constraint (ATSUSER.SYS_C004032) violated - parent key not found
          
          22:33:41,608 WARN [JDBCExceptionReporter] SQL Error: 2291, SQLState: 23000
          
          22:33:41,608 ERROR [JDBCExceptionReporter] ORA-02291: integrity constraint (ATSUSER.SYS_C004032) violated - parent key not found
          
          22:33:41,613 ERROR [AbstractFlushingEventListener] Could not synchronize database state with session
          
          org.hibernate.exception.ConstraintViolationException
          : Could not execute JDBC batch update
          
          at org.hibernate.exception.SQLStateConverter.convert(
          SQLStateConverter.java:71)
          
          at org.hibernate.exception.JDBCExceptionHelper.convert(
          JDBCExceptionHelper.java:43)
          
          at org.hibernate.jdbc.AbstractBatcher.executeBatch(
          AbstractBatcher.java:249)
          
          at org.hibernate.jdbc.AbstractBatcher.prepareStatement(
          AbstractBatcher.java:92)
          
          at org.hibernate.jdbc.AbstractBatcher.prepareStatement(
          AbstractBatcher.java:87)
          
          at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(
          AbstractBatcher.java:218)
          
          at org.hibernate.persister.entity.AbstractEntityPersister.insert(
          AbstractEntityPersister.java:2159)
          
          at org.hibernate.persister.entity.AbstractEntityPersister.insert(
          AbstractEntityPersister.java:2595)
          
          at org.hibernate.action.EntityInsertAction.execute(
          EntityInsertAction.java:51)
          
          at org.hibernate.engine.ActionQueue.execute(
          ActionQueue.java:248)
          
          at org.hibernate.engine.ActionQueue.executeActions(
          ActionQueue.java:232)
          
          at org.hibernate.engine.ActionQueue.executeActions(
          ActionQueue.java:139)
          
          at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(
          AbstractFlushingEventListener.java:298)
          
          at org.hibernate.event.def.DefaultFlushEventListener.onFlush(
          DefaultFlushEventListener.java:27)
          
          at org.hibernate.impl.SessionImpl.flush(
          SessionImpl.java:1000)
          
          at org.hibernate.impl.SessionImpl.managedFlush(
          SessionImpl.java:338)
          
          at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(
          AbstractEntityManagerImpl.java:515)
          
          at org.jboss.tm.TransactionImpl.doBeforeCompletion(
          TransactionImpl.java:1491)
          
          at org.jboss.tm.TransactionImpl.beforePrepare(
          TransactionImpl.java:1110)
          
          at org.jboss.tm.TransactionImpl.commit(
          TransactionImpl.java:324)
          
          at org.jboss.tm.TxManager.commit(
          TxManager.java:240)
          
          at org.jboss.aspects.tx.TxPolicy.endTransaction(
          TxPolicy.java:175)
          
          at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(
          TxPolicy.java:87)
          
          at org.jboss.aspects.tx.TxInterceptor$Required.invoke(
          TxInterceptor.java:191)
          
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
          MethodInvocation.java:101)
          
          at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(
          TxPropagationInterceptor.java:76)
          
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
          MethodInvocation.java:101)
          
          at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(
          StatelessInstanceInterceptor.java:62)
          
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
          MethodInvocation.java:101)
          
          at org.jboss.aspects.security.AuthenticationInterceptor.invoke(
          AuthenticationInterceptor.java:77)
          
          at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(
          Ejb3AuthenticationInterceptor.java:102)
          
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
          MethodInvocation.java:101)
          
          at org.jboss.ejb3.ENCPropagationInterceptor.invoke(
          ENCPropagationInterceptor.java:47)
          
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
          MethodInvocation.java:101)
          
          at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(
          AsynchronousInterceptor.java:106)
          
          at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(
          MethodInvocation.java:101)
          
          at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(
          StatelessContainer.java:263)
          
          at org.jboss.aop.Dispatcher.invoke(
          Dispatcher.java:106)
          
          at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(
          AOPRemotingInvocationHandler.java:82)
          
          at org.jboss.remoting.ServerInvoker.invoke(
          ServerInvoker.java:828)
          
          at org.jboss.remoting.ServerInvoker.invoke(
          ServerInvoker.java:681)
          
          at org.jboss.remoting.transport.socket.ServerThread.processInvocation(
          ServerThread.java:358)
          
          at org.jboss.remoting.transport.socket.ServerThread.dorun(
          ServerThread.java:398)
          
          at org.jboss.remoting.transport.socket.ServerThread.run(
          ServerThread.java:239)
          
          Caused by:
          java.sql.BatchUpdateException: ORA-02291: integrity constraint (ATSUSER.SYS_C004032) violated - parent key not found
          
          at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(
          DatabaseError.java:343)
          
          at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(
          OraclePreparedStatement.java:10657)
          
          at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(
          WrappedStatement.java:519)
          
          at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(
          BatchingBatcher.java:48)
          
          at org.hibernate.jdbc.AbstractBatcher.executeBatch(
          AbstractBatcher.java:242)
          
          ... 41 more


          • 2. Re: EJB3 Transaction with Oracle 10g XE
            Abhinav Nigam Newbie

            cant someone comment on this......


            i need help

            • 3. Re: EJB3 Transaction with Oracle 10g XE
              fhh Expert

              You have to post what you were doing. And check what constraint is violated.

              Regards

              Felix