2 Replies Latest reply on Apr 5, 2002 11:01 AM by Chris Schneider

    URGENT! encapsulate two entity beans in one transaction

    Chris Schneider Newbie


      basically I have statefull session bean on which i call a method. this method calls a "business method" class (no bean, just a java class) which is creating entity bean A and afterwards (depending on A) entity bean B. Now if B throws a SQLException(i.e. fractional truncation) A should be rolledback and not be stored in the database (MSSQL2000). I defined all the beans in the ejb.xml as ContainerManaged and added following transaction properties:






      but it seams that the transaction handlin form jboss2.2.2 does not work at all. I just get a SQLException back and the values of entity bean A are stored in the database! :(

      so I decided to implement my own transaction as followd:
      I changed the transaction type of the sessionbean to beanManaged and added following code

      javax.transaction.UserTransaction userTrans = this.ctx.getUserTransaction();
      BusinessMethod newSubject = new NewSubjectBM(svo, this.ui);
      //execute tries to create entity bean A and B
      //NewSubject is a normal java class
      //BusinessMethod is the abstract class newSubject
      //inherits from
      SubjectAggVO savo = (SubjectAggVO)newSubject.execute();
      } catch(Exception e){
      throw new Exception("baba bubu" + e.getMessage());
      this ends up in a deadlock

      someone please help me on this! what am I doing wrong that the normal transaction handling dosent work and why does the user defined transaction not work either.

      I realy appriciate if someone could show me some sample code which works.

      thx a lot!!