|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2009 the original author or authors. |
|
|
|
|
* Copyright 2002-2011 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -218,6 +218,7 @@ class SpringSessionSynchronization implements TransactionSynchronization, Ordere |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void afterCompletion(int status) { |
|
|
|
|
try { |
|
|
|
|
if (!this.hibernateTransactionCompletion || !this.newSession) { |
|
|
|
|
// No Hibernate TransactionManagerLookup: apply afterTransactionCompletion callback.
|
|
|
|
|
// Always perform explicit afterTransactionCompletion callback for pre-bound Session,
|
|
|
|
@ -225,9 +226,12 @@ class SpringSessionSynchronization implements TransactionSynchronization, Ordere |
|
|
|
|
Session session = this.sessionHolder.getSession(); |
|
|
|
|
// Provide correct transaction status for releasing the Session's cache locks,
|
|
|
|
|
// if possible. Else, closing will release all cache locks assuming a rollback.
|
|
|
|
|
try { |
|
|
|
|
if (session instanceof SessionImplementor) { |
|
|
|
|
((SessionImplementor) session).afterTransactionCompletion(status == STATUS_COMMITTED, null); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
finally { |
|
|
|
|
// Close the Hibernate Session here if necessary
|
|
|
|
|
// (closed in beforeCompletion in case of TransactionManagerLookup).
|
|
|
|
|
if (this.newSession) { |
|
|
|
@ -237,14 +241,18 @@ class SpringSessionSynchronization implements TransactionSynchronization, Ordere |
|
|
|
|
session.disconnect(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!this.newSession && status != STATUS_COMMITTED) { |
|
|
|
|
// Clear all pending inserts/updates/deletes in the Session.
|
|
|
|
|
// Necessary for pre-bound Sessions, to avoid inconsistent state.
|
|
|
|
|
this.sessionHolder.getSession().clear(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
finally { |
|
|
|
|
if (this.sessionHolder.doesNotHoldNonDefaultSession()) { |
|
|
|
|
this.sessionHolder.setSynchronizedWithTransaction(false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|