Discussions

EJB design: Transaction in stateless session bean

  1. Transaction in stateless session bean (1 messages)

    Like to check if the transaction context for the followings are propagated to session bean method2?

    1)
    tx begin
    sb1.method1
    sb1.method2
    tx end

    2)
    tx begin
    sb1.method1 -> sb1.method2
    tx ends

    Do explain why and how the transaction works?
    Thanks in advance.
  2. Transaction in stateless session bean[ Go to top ]

    Hi,

    tx begin
    sb1.method1
    sb1.method2
    tx end

    How the methods are called. If it is some client who has started the transaction and the client is calling method 1 and method 2 in one transaction then transaction context will propogate.

    2
    tx begin
    sb1.method1 -> sb1.method2
    tx ends

    In this case NO. Reason being you are calling mrthod2 directly from method 1 and container was never given a chance to add its services. If you will do a remote lookup in your method1 and will call method 2 then indeed the transaction context will be propogated.

    Hope it helps.