1 Reply Latest reply on Dec 18, 2004 10:05 AM by starksm64

    CMP transaction

    chatbuilder

      Hi,

      I'm using CMP entity beans.

      In my ejb-jar.xml I use:

       <assembly-descriptor>
       <container-transaction>
       <method>
       <ejb-name>Initiaal</ejb-name>
       <method-name>*</method-name>
       </method>
       <trans-attribute>Required</trans-attribute>
       </container-transaction>
       </assembly-descriptor>
      


      in my bean I have the following code
      
      
      public void update(.....) throws RemoteException, ActionException{
       if(lockindicator != getLockindicator()) throw new ActionException("data.changed.by.other.user");
       setLockindicator(lockindicator +1);
       setData(.....);
      
      }
      
      public void setData(...) throws ActionException{
      
       if("".equals(name)) throw new ActionException("name.requered");
       this.setName(...);
       this.setDate(...);
      
      }
      


      when I update a record from my servlet I use the update method, with some parameters. When my name is empty I receive an exception. But the problem is that my lockindicator isn't rolled back. He increased with 1.


      My question is if the transaction works only for one method. Or is the transaction "multi-method".

      Thx in adv.
      Pieter


        • 1. Re: CMP transaction
          starksm64

          The transaction propagates depending on the tags of all the methods involved. The default of Required does propagate the transaction. Throwing a checked exception does not rollback the transaction so if that is the behavior your looking for use the setRollbackOnly method on the ejb context before throwing the exception.