From d12396ee372627c7e5bf46cce92fccc88b39379e Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Tue, 29 Nov 2011 19:14:29 +0000 Subject: [PATCH] HHH-6862 Reuse cached entryArray of IdentityMap in StatefulPersistenceContext as much as possible --- .../engine/internal/StatefulPersistenceContext.java | 4 ++-- .../event/internal/AbstractFlushingEventListener.java | 6 +++--- .../hibernate/internal/util/collections/IdentityMap.java | 4 ---- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java index 14c837ea6d..62eac77a4f 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java @@ -1162,7 +1162,7 @@ public class StatefulPersistenceContext implements PersistenceContext { //not found in case, proceed // iterate all the entities currently associated with the persistence context. - for ( Entry me : IdentityMap.entriesIterable( entityEntries ) ) { + for ( Entry me : IdentityMap.concurrentEntries( entityEntries ) ) { final EntityEntry entityEntry = me.getValue(); // does this entity entry pertain to the entity persister in which we are interested (owner)? if ( persister.isSubclassEntityName( entityEntry.getEntityName() ) ) { @@ -1284,7 +1284,7 @@ public class StatefulPersistenceContext implements PersistenceContext { } //Not found in cache, proceed - for ( Entry me : IdentityMap.entriesIterable( entityEntries ) ) { + for ( Entry me : IdentityMap.concurrentEntries( entityEntries ) ) { EntityEntry ee = me.getValue(); if ( persister.isSubclassEntityName( ee.getEntityName() ) ) { Object instance = me.getKey(); diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java index 1a950fd073..6f1422e8a1 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java @@ -187,7 +187,7 @@ public abstract class AbstractFlushingEventListener implements Serializable { LOG.debug( "Dirty checking collections" ); for ( Map.Entry entry : - IdentityMap.entriesIterable( (Map) persistenceContext.getCollectionEntries() )) { + IdentityMap.concurrentEntries( (Map) persistenceContext.getCollectionEntries() )) { entry.getValue().preFlush( entry.getKey() ); } } @@ -246,7 +246,7 @@ public abstract class AbstractFlushingEventListener implements Serializable { LOG.trace( "Processing unreferenced collections" ); for ( Map.Entry me : - IdentityMap.entriesIterable( (Map) persistenceContext.getCollectionEntries() )) { + IdentityMap.concurrentEntries( (Map) persistenceContext.getCollectionEntries() )) { CollectionEntry ce = me.getValue(); if ( !ce.isReached() && !ce.isIgnore() ) { Collections.processUnreachableCollection( me.getKey(), session ); @@ -259,7 +259,7 @@ public abstract class AbstractFlushingEventListener implements Serializable { ActionQueue actionQueue = session.getActionQueue(); for ( Map.Entry me : - IdentityMap.entriesIterable( (Map) persistenceContext.getCollectionEntries() )) { + IdentityMap.concurrentEntries( (Map) persistenceContext.getCollectionEntries() )) { PersistentCollection coll = me.getKey(); CollectionEntry ce = me.getValue(); diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/IdentityMap.java b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/IdentityMap.java index 1183fbb75c..4553d5fdb0 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/IdentityMap.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/IdentityMap.java @@ -90,10 +90,6 @@ public final class IdentityMap implements Map { return ( (IdentityMap) map ).entryArray(); } - public static Iterable> entriesIterable(Map map) { - return ( (IdentityMap) map ).entryList(); - } - public static Iterator keyIterator(Map map) { return ( (IdentityMap) map ).keyIterator(); }