|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.transaction.support.TransactionSynchronizationAdapter
org.springframework.orm.hibernate.SpringSessionSynchronization
class SpringSessionSynchronization
Callback for resource cleanup at the end of a Spring-managed JTA transaction, that is, when participating in a JtaTransactionManager transaction.
SessionFactoryUtils
,
JtaTransactionManager
Field Summary |
---|
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 | |
---|---|
SpringSessionSynchronization(SessionHolder sessionHolder,
net.sf.hibernate.SessionFactory sessionFactory,
SQLExceptionTranslator jdbcExceptionTranslator,
boolean newSession)
|
Method Summary | |
---|---|
void |
afterCompletion(int status)
Invoked after transaction commit/rollback. |
void |
beforeCommit(boolean readOnly)
Invoked before transaction commit (before "beforeCompletion"). |
void |
beforeCompletion()
Invoked before transaction commit/rollback. |
int |
getOrder()
Return the order value of this object, with a higher value meaning greater in terms of sorting. |
void |
resume()
Resume this synchronization. |
void |
suspend()
Suspend this synchronization. |
Methods inherited from class org.springframework.transaction.support.TransactionSynchronizationAdapter |
---|
afterCommit |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SpringSessionSynchronization(SessionHolder sessionHolder, net.sf.hibernate.SessionFactory sessionFactory, SQLExceptionTranslator jdbcExceptionTranslator, boolean newSession)
Method Detail |
---|
public int getOrder()
Ordered
Normally starting with 0 or 1, with Ordered.LOWEST_PRECEDENCE
indicating greatest. Same order values will result in arbitrary
positions for the affected objects.
Higher value can be interpreted as lower priority, consequently the first object has highest priority (somewhat analogous to Servlet "load-on-startup" values).
Note that order values below 0 are reserved for framework purposes. Application-specified values should always be 0 or greater, with only framework components (internal or third-party) supposed to use lower values.
getOrder
in interface Ordered
getOrder
in class TransactionSynchronizationAdapter
Ordered.LOWEST_PRECEDENCE
public void suspend()
TransactionSynchronization
suspend
in interface TransactionSynchronization
suspend
in class TransactionSynchronizationAdapter
TransactionSynchronizationManager.unbindResource(java.lang.Object)
public void resume()
TransactionSynchronization
resume
in interface TransactionSynchronization
resume
in class TransactionSynchronizationAdapter
TransactionSynchronizationManager.bindResource(java.lang.Object, java.lang.Object)
public void beforeCommit(boolean readOnly) throws DataAccessException
TransactionSynchronization
This callback does not mean that the transaction will actually be committed. A rollback decision can still occur after this method has been called. This callback is rather meant to perform work that's only relevant if a commit still has a chance to happen, such as flushing SQL statements to the database.
Note that exceptions will get propagated to the commit caller and cause a rollback of the transaction.
beforeCommit
in interface TransactionSynchronization
beforeCommit
in class TransactionSynchronizationAdapter
readOnly
- whether the transaction is defined as read-only transaction
DataAccessException
TransactionSynchronization.beforeCompletion()
public void beforeCompletion()
TransactionSynchronization
This method will be invoked after beforeCommit
, even when
beforeCommit
threw an exception. This callback allows for
closing resources before transaction completion, for any outcome.
beforeCompletion
in interface TransactionSynchronization
beforeCompletion
in class TransactionSynchronizationAdapter
TransactionSynchronization.beforeCommit(boolean)
,
TransactionSynchronization.afterCompletion(int)
public void afterCompletion(int status)
TransactionSynchronization
afterCompletion
in interface TransactionSynchronization
afterCompletion
in class TransactionSynchronizationAdapter
status
- completion status according to the STATUS_*
constantsTransactionSynchronization.STATUS_COMMITTED
,
TransactionSynchronization.STATUS_ROLLED_BACK
,
TransactionSynchronization.STATUS_UNKNOWN
,
TransactionSynchronization.beforeCompletion()
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |