2 Replies Latest reply on Dec 6, 2004 10:56 AM by Scott Stark

    CMP Transaction

    Victor Batista Newbie

      Hi!
      I have a CMP Entity Bean which requires a Transaction by default for all its methods. I have the following Xdoclet tag on the class definition:
      * @ejb.transaction type = "Required"

      Than I have a getValueObject() which is defined as:

      /**
      * @ejb:interface-method view-type="both"
      *
      * @ejb.transaction type = "Supports"
      **/
      public Xpto getValueObject() {
      Xpto xpto = new Xpto();
      xpto.setA(getA());
      return xpto;
      }

      ...

      /**
      * @ejb:persistent-field
      * @ejb:pk-field
      *
      * @jboss:column-name name="XPTO_A"
      **/
      public abstract int getA();

      /**
      **/
      public abstract void setA( int id);


      Method getA() is not defined on the bean interface. Will a transaction be created when I call getValueObject() (without being enrolled in a previous transaction)?
      I have Transaction required for all methods, except getValueObject() which is supports...

      The @ejb.transaction defined at class level applies only to the methods exposed on the Bean Interfaces, or does it apply even for non-exposed methods?

      Thanks in advance,
      Victor Batista


      PS: The same applies for a session bean method (supports transaction) which calls a private method (the default for the bean transaction is Required). Will a transaction be created on this case?

        • 1. Re: CMP Transaction
          Sven Baumgarten Newbie

          I've an additional question to that topic:

          I've a Session Bean with two methods methodA() and mehtodB(). mehtodA has transaction attribute "required" and mehtodB "requiresNew".

          If I call mehtodB from mehtodA by "mehtodB()" mehtodB runs in the same transaction as mehtodA.
          If I call mehtodB from mehtodA by "(() sessionContext.getEJBObject()).mehtodB()" mehtodB runs in a new transaction.

          What is the difference? Is this J2EE standard or JBoss specific?

          • 2. Re: CMP Transaction
            Scott Stark Master

            required, required new semantics are standard j2ee.

            the behavior of accessing a cmp getter from a method with supports is undefined and application server specific.