HHH-14093 Make StatefulPersistenceContext#registerInsertedKey and StatefulPersistenceContext#wasInsertedDuringTransaction use HashSet instead of ArrayList
This commit is contained in:
parent
677a65a8cf
commit
f1243a3285
|
@ -18,7 +18,6 @@ import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
@ -1831,7 +1830,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
|
|
||||||
// INSERTED KEYS HANDLING ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// INSERTED KEYS HANDLING ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
private HashMap<String,List<Serializable>> insertedKeysMap;
|
private HashMap<String, HashSet<Serializable>> insertedKeysMap;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerInsertedKey(EntityPersister persister, Serializable id) {
|
public void registerInsertedKey(EntityPersister persister, Serializable id) {
|
||||||
|
@ -1841,11 +1840,10 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
insertedKeysMap = new HashMap<>();
|
insertedKeysMap = new HashMap<>();
|
||||||
}
|
}
|
||||||
final String rootEntityName = persister.getRootEntityName();
|
final String rootEntityName = persister.getRootEntityName();
|
||||||
List<Serializable> insertedEntityIds = insertedKeysMap.get( rootEntityName );
|
HashSet<Serializable> insertedEntityIds = insertedKeysMap.computeIfAbsent(
|
||||||
if ( insertedEntityIds == null ) {
|
rootEntityName,
|
||||||
insertedEntityIds = new ArrayList<>();
|
k -> new HashSet<>()
|
||||||
insertedKeysMap.put( rootEntityName, insertedEntityIds );
|
);
|
||||||
}
|
|
||||||
insertedEntityIds.add( id );
|
insertedEntityIds.add( id );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1855,7 +1853,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
// again, we only really care if the entity is cached
|
// again, we only really care if the entity is cached
|
||||||
if ( persister.canWriteToCache() ) {
|
if ( persister.canWriteToCache() ) {
|
||||||
if ( insertedKeysMap != null ) {
|
if ( insertedKeysMap != null ) {
|
||||||
final List<Serializable> insertedEntityIds = insertedKeysMap.get( persister.getRootEntityName() );
|
final HashSet<Serializable> insertedEntityIds = insertedKeysMap.get( persister.getRootEntityName() );
|
||||||
if ( insertedEntityIds != null ) {
|
if ( insertedEntityIds != null ) {
|
||||||
return insertedEntityIds.contains( id );
|
return insertedEntityIds.contains( id );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue