2 Replies Latest reply on May 29, 2006 3:41 AM by sajid2045

    Client Controlled Transactions

    brigl

      Hi,

      does anyone know how can I controll transactions on the client. I wrote a small client getting an UserTransaction:

      MyStatefulSession ejb = (MyStatefulSession) ctx.lookup("..
      UserTransaction tx = (UserTransaction) ctx.lookup(...

      tx.begin();
      ejb.method1("someString");
      tx.rollback();


      The stateful session bean has declared an EntityManager with @PersistenceContext(type = PersistenceContextType.EXTENDED)

      if I invoke the method1(String) the objects created inside are stored all on the DB, even if the UserTransaction outside is rollbacked. Only if the method1 is declared @PersistenceContext(type = @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) the transaction is rollbacked correctly.

      Is this the expected behavior? Should the methods be declared always to NOT_SUPPORTED on Application Transactions?

        • 1. Re: Client Controlled Transactions
          brigl

          I noted the persist() on the EntityManager does perform always perfom a storing of the object, already before the method has been completed. Even an if an ApplicationException(marked as rollback) is thrown, the object will be stored. Isn't there any method to mark an object only, as it will be stored only on commit?

          • 2. Re: Client Controlled Transactions
            sajid2045

            I ran through this type of problem...But the problem was caused by the database i was using
            ( SQL without innodb support). So my database was not supporting transactions. I hope it's not the case with you too.
            sajid