posted 15 years ago
Transaction synchronization means that the entity manager registers at the JTA transaction and will be informed from the transaction when a commit or rollback occurs. Every entity manager type (container-managed as well as application-managed) and any number of entity managers can be synchronized with the transaction.
Transaction Association has to do with sharing a persistence context and affects only container-managed entity managers: The first container-managed entity manager em1 those methods are called within a JTA transaction associates its persistence context with this transaction. If a method of a second container-managed entity manager em2 is called within the same transaction afterwards, em2 realizes that there is alreday an persistence context associated with the transaction. Therefore em2 won't create a new persistence context but uses the one from em1 instead. So em1 and em2 share the same persistence context. At most one persistence context can be associated with a JTA transaction.
SCJP 5 (98%) - SCBCD 5 (98%)