0

I have been working with ejb 2.0 for past 2 years on my application and suddenly stuck with a problem where I just want to call a method before and after transaction to database.

I am sure EJB 3.0 has interceptors to deal with this problem but any idea about EJB 2.0 that how to achieve it.

4

1 回答 1

0

Your bean can implement the interface SessionSynchronization. I think it's pretty old and was already in EJB 2.x.

Alternatively, there's javax.transaction.Synchronization and javax.transaction.TransactionSynchronizationRegistry that you can use to register callback.

This question discusses differences between the two; it seems to be unreliable to use SessionSynchronization for SLSB. I would recommend to read the relevant parts of the spec to understand precisely how they work.

于 2013-06-21T13:41:00.830 回答