HHH-7309 bug-fix

This commit is contained in:
Guenther Demetz 2012-05-09 11:46:49 +02:00 committed by brmeyer
parent 7c218bbe11
commit a176931349
1 changed files with 6 additions and 3 deletions

View File

@ -1862,14 +1862,14 @@ public class StatefulPersistenceContext implements PersistenceContext {
CachedNaturalIdValueSource source) {
final NaturalIdRegionAccessStrategy naturalIdCacheAccessStrategy = persister.getNaturalIdCacheAccessStrategy();
final NaturalIdCacheKey naturalIdCacheKey = new NaturalIdCacheKey( naturalIdValues, persister, session );
if (naturalIdCacheAccessStrategy.get(naturalIdCacheKey, session.getTimestamp()) != null) {
return; // prevent identical re-cachings
}
final SessionFactoryImplementor factory = session.getFactory();
switch ( source ) {
case LOAD: {
if (naturalIdCacheAccessStrategy.get(naturalIdCacheKey, session.getTimestamp()) != null) {
return; // prevent identical re-cachings
}
final boolean put = naturalIdCacheAccessStrategy.putFromLoad(
naturalIdCacheKey,
id,
@ -1916,6 +1916,9 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
case UPDATE: {
final NaturalIdCacheKey previousCacheKey = new NaturalIdCacheKey( previousNaturalIdValues, persister, session );
if (naturalIdCacheKey.equals(previousCacheKey)) {
return; // prevent identical re-caching, solves HHH-7309
}
final SoftLock removalLock = naturalIdCacheAccessStrategy.lockItem( previousCacheKey, null );
naturalIdCacheAccessStrategy.remove( previousCacheKey );