2 Replies Latest reply on Oct 2, 2006 5:11 AM by Markus Pielmeier

    Transactions Rollback

    Markus Pielmeier Newbie

      Hello Experts,

      I've got a problem with the rollback of failed transactions. My situation is as follows:

      @Stateless
      @Local
      public class BeanA implements IBeanA{
      
       @PersistenceContext(name="MyContext")
       private EntityManager entityManager;
      
       public void persistSomething() {
       entityManager.persist(new MyEntityBean());
       }
      }
      


      @Stateless
      @Remote
      public class BeanB implements IBeanB{
      
       @EJB
       private IBeanA beanA;
      
       public void doSomething() {
       beanA.persistSomething();
      
       throw new RuntimeException();
       }
      }
      


      The persistSomething and the doSomething methods are part of my business interfaces.

      My problem is, that the persisted entity bean isen't rolled back from the database after the RuntimeException.
      I've even tried to set the beanA's business method to TransactionAttributeType.MANDATORY so I can make sure that I'm always in the same transaction.

      Do I understand the EJB 3.0 transaction model wrong? I thought as long as my transaction spreads over one thread, then all the changes are rolled back.

      Do I need application transactions in this case?


      Thanks in advances