1 Reply Latest reply on Aug 28, 2008 10:44 AM by marx3

    Rollback transaction

    marx3

      How to rollback transaction in conversation bean managed by container? I use Seam managed transaction because it helps me with lazyInitializationException, so I can't manually manage transactions.


      1)Simply throwing exception cause displaying debug page


      2)throwing exception from method annotated with


      @TransactionAttribute(value = REQUIRES_NEW)
      @Transactional(TransactionPropagationType.REQUIRED)
      


      and catching it in another method doesn't rollback transaction at all.


      2)


      @Resource
      protected SessionContext sessionContext;
      sessionContext.setRollbackOnly
      



      cause something strange with conversation - while transaction rollbacks, application state is incosistent.


      3)Any try with:


      (PersistentContext/entitiManager).getTransaction().rollback();



      cause


      Caused by: javax.ejb.EJBTransactionRolledbackException: JTA EntityManager cannot access a transactions



      which is logical.


      4)I can do:


      @Begin(flushMode=FlushModeType.MANUAL)



      but there is no entitymanager.rollback or sth similair, so how to rollback?