In
this article, BEA folks share some experience on the use of the SessionSynchronization interface.
[...]
the typical use case of the SessionSynchronization interface is a stateful session bean with its beforeCompletion method containing an implementation that flushes any state that may have been cached before the commit processing begins (of course, if state is cached when the transaction is committed, then it will never be written to the back-end storage). The afterCompletion implementation, when the final result is a JTA rollback, will likely return the session state to some values saved prior to its commencement.
[...]