1

I'm new in EJB. I've read that one of the side effects of bean-managed transactions (BMT) is that transaction doesn't propagates if we call method of another BMT bean. But due to the third ACID property (isolating) does it mean that the second method (inner) won't see the changes that were made in the first methods (outer)?

Roman C
  • 49,761
  • 33
  • 66
  • 176
VB_
  • 45,112
  • 42
  • 145
  • 293

1 Answers1

1

Bean-managed transactions only means that you code the transaction boundaries in your bean yourself.

Whereas Container-managed transactions means that you let the container (i.e. the application server) do the dirty work of opening, closing, rollbacking, ... your transactions for you.

In both cases, usually some central TransactionManager is used to access the current transaction or create a new one.

does it mean that the second method (inner) won't see the changes that were made in the first methods (outer)

If you use the same TransactionManager (and the same Transaction) in both methods, the inner method should see the changes of the outer.

Tom
  • 3,913
  • 19
  • 28
  • But how to use the same transaction/transaction manager in two methods of two stateless beans, for example.Do I need to pass them is method arguments? – VB_ Jun 24 '13 at 07:31
  • 1
    When using EJB, you can inject a EJBContext with the @Resource annotation and then call context.getUserTransaction() to get a transaction. You shouldn't need to pass the transaction from your outer method to your inner method, because the framework you use (hibernate for database access, for example) automatically uses the currently open transaction. – Tom Jun 24 '13 at 21:45