mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 08:05:05 +00:00
HHH-8409 Improve usage of ConcurrentMaps by using putIfAbsent in StatefulPersistenceContext
This commit is contained in:
parent
1bed587355
commit
168c06d062
@ -37,6 +37,7 @@
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
@ -109,7 +110,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||
// private Map<Object,EntityEntry> entityEntries;
|
||||
|
||||
// Entity proxies, by EntityKey
|
||||
private Map<EntityKey, Object> proxiesByKey;
|
||||
private ConcurrentMap<EntityKey, Object> proxiesByKey;
|
||||
|
||||
// Snapshots of current database state for entities
|
||||
// that have *not* been loaded
|
||||
@ -563,9 +564,7 @@ private void reassociateProxy(LazyInitializer li, HibernateProxy proxy) {
|
||||
final EntityPersister persister = session.getFactory().getEntityPersister( li.getEntityName() );
|
||||
final EntityKey key = session.generateEntityKey( li.getIdentifier(), persister );
|
||||
// any earlier proxy takes precedence
|
||||
if ( !proxiesByKey.containsKey( key ) ) {
|
||||
proxiesByKey.put( key, proxy );
|
||||
}
|
||||
proxiesByKey.putIfAbsent( key, proxy );
|
||||
proxy.getHibernateLazyInitializer().setSession( session );
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user