org.springframework.orm.jpa
Class EntityManagerFactoryUtils.EntityManagerSynchronization

java.lang.Object
  extended by org.springframework.transaction.support.ResourceHolderSynchronization<EntityManagerHolder,EntityManagerFactory>
      extended by org.springframework.orm.jpa.EntityManagerFactoryUtils.EntityManagerSynchronization
All Implemented Interfaces:
Ordered, TransactionSynchronization
Enclosing class:
EntityManagerFactoryUtils

private static class EntityManagerFactoryUtils.EntityManagerSynchronization
extends ResourceHolderSynchronization<EntityManagerHolder,EntityManagerFactory>
implements Ordered

Callback for resource cleanup at the end of a non-JPA transaction (e.g. when participating in a JtaTransactionManager transaction).

See Also:
JtaTransactionManager

Field Summary
private  JpaDialect jpaDialect
           
private  boolean newEntityManager
           
private  java.lang.Object transactionData
           
 
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
EntityManagerFactoryUtils.EntityManagerSynchronization(EntityManagerHolder emHolder, EntityManagerFactory emf, java.lang.Object txData, boolean newEm)
           
 
Method Summary
protected  void cleanupResource(EntityManagerHolder resourceHolder, EntityManagerFactory resourceKey, boolean committed)
          Perform a cleanup on the given resource (which is left bound to the thread).
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  void releaseResource(EntityManagerHolder resourceHolder, EntityManagerFactory resourceKey)
          Release the given resource (after it has been unbound from the thread).
protected  boolean shouldUnbindAtCompletion()
          Return whether this holder should be unbound at completion (or should rather be left bound to the thread after the transaction).
 
Methods inherited from class org.springframework.transaction.support.ResourceHolderSynchronization
afterCommit, afterCompletion, beforeCommit, beforeCompletion, flush, processResourceAfterCommit, resume, shouldReleaseBeforeCompletion, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transactionData

private final java.lang.Object transactionData

jpaDialect

private final JpaDialect jpaDialect

newEntityManager

private final boolean newEntityManager
Constructor Detail

EntityManagerFactoryUtils.EntityManagerSynchronization

public EntityManagerFactoryUtils.EntityManagerSynchronization(EntityManagerHolder emHolder,
                                                              EntityManagerFactory emf,
                                                              java.lang.Object txData,
                                                              boolean newEm)
Method Detail

getOrder

public int getOrder()
Description copied from interface: Ordered
Return the order value of this object, with a higher value meaning greater in terms of sorting.

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).

Specified by:
getOrder in interface Ordered
Returns:
the order value

flushResource

protected void flushResource(EntityManagerHolder resourceHolder)
Description copied from class: ResourceHolderSynchronization
Flush callback for the given resource holder.

Overrides:
flushResource in class ResourceHolderSynchronization<EntityManagerHolder,EntityManagerFactory>
Parameters:
resourceHolder - the resource holder to flush

shouldUnbindAtCompletion

protected boolean shouldUnbindAtCompletion()
Description copied from class: ResourceHolderSynchronization
Return whether this holder should be unbound at completion (or should rather be left bound to the thread after the transaction).

The default implementation returns true.

Overrides:
shouldUnbindAtCompletion in class ResourceHolderSynchronization<EntityManagerHolder,EntityManagerFactory>

releaseResource

protected void releaseResource(EntityManagerHolder resourceHolder,
                               EntityManagerFactory resourceKey)
Description copied from class: ResourceHolderSynchronization
Release the given resource (after it has been unbound from the thread).

Overrides:
releaseResource in class ResourceHolderSynchronization<EntityManagerHolder,EntityManagerFactory>
Parameters:
resourceHolder - the resource holder to process
resourceKey - the key that the ResourceHolder was bound for

cleanupResource

protected void cleanupResource(EntityManagerHolder resourceHolder,
                               EntityManagerFactory resourceKey,
                               boolean committed)
Description copied from class: ResourceHolderSynchronization
Perform a cleanup on the given resource (which is left bound to the thread).

Overrides:
cleanupResource in class ResourceHolderSynchronization<EntityManagerHolder,EntityManagerFactory>
Parameters:
resourceHolder - the resource holder to process
resourceKey - the key that the ResourceHolder was bound for
committed - whether the transaction has committed (true) or rolled back (false)