This commit is contained in:
Guenther Demetz 2012-04-26 12:20:30 +03:00 committed by Steve Ebersole
parent 23aa8875d8
commit bd5e97c201
1 changed files with 16 additions and 8 deletions

View File

@ -1833,11 +1833,16 @@ public class StatefulPersistenceContext implements PersistenceContext {
new AfterTransactionCompletionProcess() {
@Override
public void doAfterTransactionCompletion(boolean success, SessionImplementor session) {
final boolean put = naturalIdCacheAccessStrategy.afterInsert( naturalIdCacheKey, id );
if (success) {
final boolean put = naturalIdCacheAccessStrategy.afterInsert( naturalIdCacheKey, id );
if ( put && factory.getStatistics().isStatisticsEnabled() ) {
factory.getStatisticsImplementor()
if ( put && factory.getStatistics().isStatisticsEnabled() ) {
factory.getStatisticsImplementor()
.naturalIdCachePut( naturalIdCacheAccessStrategy.getRegion().getName() );
}
}
else {
naturalIdCacheAccessStrategy.remove(naturalIdCacheKey);
}
}
}
@ -1862,14 +1867,17 @@ public class StatefulPersistenceContext implements PersistenceContext {
@Override
public void doAfterTransactionCompletion(boolean success, SessionImplementor session) {
naturalIdCacheAccessStrategy.unlockItem( previousCacheKey, removalLock );
final boolean put = naturalIdCacheAccessStrategy.afterUpdate( naturalIdCacheKey, id, lock );
if (success) {
final boolean put = naturalIdCacheAccessStrategy.afterUpdate( naturalIdCacheKey, id, lock );
if ( put && factory.getStatistics().isStatisticsEnabled() ) {
factory.getStatisticsImplementor()
if ( put && factory.getStatistics().isStatisticsEnabled() ) {
factory.getStatisticsImplementor()
.naturalIdCachePut( naturalIdCacheAccessStrategy.getRegion().getName() );
}
}
else {
naturalIdCacheAccessStrategy.unlockItem( naturalIdCacheKey, lock );
}
naturalIdCacheAccessStrategy.unlockItem( naturalIdCacheKey, lock );
}
}
);