transaction

Discussions

EJB programming & troubleshooting: transaction

  1. transaction (6 messages)

    just curious ... are there any way we can tell which transaction the bean (entity / session / mdbean) is currently within when processing?

    can we retreieve that from the entitycontext or sessioncontext?...

    that will be awesome if we can do it...
    thx.
    hoi

    Threaded Messages (6)

  2. transaction[ Go to top ]

    What do you mean "which transaction"? Do you mean you want to know if a transaction is already pending? Do you mean you want to know the state of that transaction?

    Dave Wolf
    The Scupper Group
    dave at scuppergroup dot com
  3. transaction[ Go to top ]

    mmmmm i think best with code.. i meant:
    e.g.

       public class BeanA implements EntityBean {
           ...
           public void call() throws RemoteException {
              // look up bean B
              beanB.doSomething();
           }
           ..
       }



       public class BeanB implements EntityBean {
           
           public void doSomething() ..
               // are there any way we can tell
               // if this method call of this
               // instance is already within an
               // transaction?
               // if yes can we retrieve that transaction's ID?
               // or anything that represent that transaction?
           }
        }


         
    when beanB is being called, are there anyway we can
    tell if the method that is being called is executed
    within an existing transaction? if yes are there
    any way we can retrieve the information about the
    transaction?..

    thx...
    -hoi.
  4. transaction[ Go to top ]

    If you use declarative transactions you dont have to do anything. If both beans are marked as requires transaction the transaction will be managed by the container.

    Dave Wolf
    The Scupper Group
    dave@scuppergroup.com
  5. transaction[ Go to top ]

    thanks... but are there anyway we can do some explicit checking on which specific transaction the method call in BeanB is within?...
  6. transaction[ Go to top ]

    Yes you can check the status with the EJBContext object. It will be passed into you at the setSessionContext() method.

    _context.getUserTransaction().getStatus();


    Dave Wolf
    The Scupper Group
    dave at scuppergroup dot com

  7. transaction[ Go to top ]

    awesome... thanks a lot...