|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.transaction.support.ResourceHolderSynchronization<EntityManagerHolder,EntityManager>
org.springframework.orm.jpa.ExtendedEntityManagerCreator.ExtendedEntityManagerSynchronization
private static class ExtendedEntityManagerCreator.ExtendedEntityManagerSynchronization
TransactionSynchronization enlisting an extended EntityManager with a current Spring transaction.
Field Summary | |
---|---|
private EntityManager |
entityManager
|
private PersistenceExceptionTranslator |
exceptionTranslator
|
Fields inherited from interface org.springframework.core.Ordered |
---|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
Fields inherited from interface org.springframework.transaction.support.TransactionSynchronization |
---|
STATUS_COMMITTED, STATUS_ROLLED_BACK, STATUS_UNKNOWN |
Constructor Summary | |
---|---|
ExtendedEntityManagerCreator.ExtendedEntityManagerSynchronization(EntityManager em,
PersistenceExceptionTranslator exceptionTranslator)
|
Method Summary | |
---|---|
void |
afterCommit()
Invoked after transaction commit. |
void |
afterCompletion(int status)
Invoked after transaction commit/rollback. |
private java.lang.RuntimeException |
convertException(java.lang.RuntimeException ex)
|
protected void |
flushResource(EntityManagerHolder resourceHolder)
Flush callback for the given resource holder. |
int |
getOrder()
Return the order value of this object, with a higher value meaning greater in terms of sorting. |
protected boolean |
shouldReleaseBeforeCompletion()
Return whether this holder's resource should be released before transaction completion ( true ) or rather after
transaction completion (false ). |
Methods inherited from class org.springframework.transaction.support.ResourceHolderSynchronization |
---|
beforeCommit, beforeCompletion, cleanupResource, flush, processResourceAfterCommit, releaseResource, resume, shouldUnbindAtCompletion, suspend |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final EntityManager entityManager
private final PersistenceExceptionTranslator exceptionTranslator
Constructor Detail |
---|
public ExtendedEntityManagerCreator.ExtendedEntityManagerSynchronization(EntityManager em, PersistenceExceptionTranslator exceptionTranslator)
Method Detail |
---|
public int getOrder()
Ordered
Normally starting with 0, with Integer.MAX_VALUE
indicating the greatest value. Same order values will result
in arbitrary positions for the affected objects.
Higher values can be interpreted as lower priority. As a consequence, the object with the lowest value has highest priority (somewhat analogous to Servlet "load-on-startup" values).
getOrder
in interface Ordered
protected void flushResource(EntityManagerHolder resourceHolder)
ResourceHolderSynchronization
flushResource
in class ResourceHolderSynchronization<EntityManagerHolder,EntityManager>
resourceHolder
- the resource holder to flushprotected boolean shouldReleaseBeforeCompletion()
ResourceHolderSynchronization
true
) or rather after
transaction completion (false
).
Note that resources will only be released when they are
unbound from the thread (ResourceHolderSynchronization.shouldUnbindAtCompletion()
).
The default implementation returns true
.
shouldReleaseBeforeCompletion
in class ResourceHolderSynchronization<EntityManagerHolder,EntityManager>
ResourceHolderSynchronization.releaseResource(H, K)
public void afterCommit()
TransactionSynchronization
Can e.g. commit further operations that are supposed to follow on a successful commit of the main transaction, like confirmation messages or emails.
NOTE: The transaction will have been committed already, but the
transactional resources might still be active and accessible. As a consequence,
any data access code triggered at this point will still "participate" in the
original transaction, allowing to perform some cleanup (with no commit following
anymore!), unless it explicitly declares that it needs to run in a separate
transaction. Hence: Use PROPAGATION_REQUIRES_NEW
for any
transactional operation that is called from here.
afterCommit
in interface TransactionSynchronization
afterCommit
in class ResourceHolderSynchronization<EntityManagerHolder,EntityManager>
public void afterCompletion(int status)
TransactionSynchronization
NOTE: The transaction will have been committed or rolled back already,
but the transactional resources might still be active and accessible. As a
consequence, any data access code triggered at this point will still "participate"
in the original transaction, allowing to perform some cleanup (with no commit
following anymore!), unless it explicitly declares that it needs to run in a
separate transaction. Hence: Use PROPAGATION_REQUIRES_NEW
for any transactional operation that is called from here.
afterCompletion
in interface TransactionSynchronization
afterCompletion
in class ResourceHolderSynchronization<EntityManagerHolder,EntityManager>
status
- completion status according to the STATUS_*
constantsTransactionSynchronization.STATUS_COMMITTED
,
TransactionSynchronization.STATUS_ROLLED_BACK
,
TransactionSynchronization.STATUS_UNKNOWN
,
TransactionSynchronization.beforeCompletion()
private java.lang.RuntimeException convertException(java.lang.RuntimeException ex)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |