@Nullable abstract fun prepareTransaction(entityManager: EntityManager, readOnly: Boolean, @Nullable name: String): Any
Prepare a JPA transaction, applying the specified semantics. Called by EntityManagerFactoryUtils when enlisting an EntityManager in a JTA transaction or a locally joined transaction (e.g. after upgrading an unsynchronized EntityManager to a synchronized one).
An implementation can apply the read-only flag as flush mode. In that case, a transaction data object can be returned that holds the previous flush mode (and possibly other data), to be reset in cleanupTransaction.
Implementations can also use the Spring transaction name to optimize for specific data access use cases (effectively using the current transaction name as use case identifier).
entityManager - the EntityManager to begin a JPA transaction on
readOnly - whether the transaction is supposed to be read-only
name - the name of the transaction (if any)
javax.persistence.PersistenceException - if thrown by JPA methods
Return
an arbitrary object that holds transaction data, if any (to be passed into cleanupTransaction)
See Also
#cleanupTransaction