HHH-6862 Switch to use Iterable from Iterator in IdentityMap helpers

This commit is contained in:
Sanne Grinovero 2011-11-29 18:55:04 +00:00 committed by Strong Liu
parent aa4954be8b
commit ad3afa4b7d
3 changed files with 11 additions and 18 deletions

View File

@ -1162,9 +1162,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
//not found in case, proceed //not found in case, proceed
// iterate all the entities currently associated with the persistence context. // iterate all the entities currently associated with the persistence context.
Iterator<Entry<Object,EntityEntry>> entities = IdentityMap.entriesIterator( entityEntries ); for ( Entry<Object,EntityEntry> me : IdentityMap.entriesIterable( entityEntries ) ) {
while ( entities.hasNext() ) {
final Map.Entry<Object,EntityEntry> me = entities.next();
final EntityEntry entityEntry = me.getValue(); final EntityEntry entityEntry = me.getValue();
// does this entity entry pertain to the entity persister in which we are interested (owner)? // does this entity entry pertain to the entity persister in which we are interested (owner)?
if ( persister.isSubclassEntityName( entityEntry.getEntityName() ) ) { if ( persister.isSubclassEntityName( entityEntry.getEntityName() ) ) {
@ -1286,9 +1284,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
} }
//Not found in cache, proceed //Not found in cache, proceed
Iterator<Entry<Object,EntityEntry>> entities = IdentityMap.entriesIterator( entityEntries ); for ( Entry<Object, EntityEntry> me : IdentityMap.entriesIterable( entityEntries ) ) {
while ( entities.hasNext() ) {
Map.Entry<Object,EntityEntry> me = entities.next();
EntityEntry ee = me.getValue(); EntityEntry ee = me.getValue();
if ( persister.isSubclassEntityName( ee.getEntityName() ) ) { if ( persister.isSubclassEntityName( ee.getEntityName() ) ) {
Object instance = me.getKey(); Object instance = me.getKey();

View File

@ -186,10 +186,9 @@ public abstract class AbstractFlushingEventListener implements Serializable {
LOG.debug( "Dirty checking collections" ); LOG.debug( "Dirty checking collections" );
Iterator<Map.Entry<PersistentCollection,CollectionEntry>> entriesIterator = IdentityMap.entriesIterator( persistenceContext.getCollectionEntries() ); for ( Map.Entry<PersistentCollection,CollectionEntry> entry :
while ( entriesIterator.hasNext() ) { IdentityMap.entriesIterable( (Map<PersistentCollection,CollectionEntry>) persistenceContext.getCollectionEntries() )) {
Map.Entry<PersistentCollection,CollectionEntry> e = entriesIterator.next(); entry.getValue().preFlush( entry.getKey() );
e.getValue().preFlush( e.getKey() );
} }
} }
@ -246,9 +245,8 @@ public abstract class AbstractFlushingEventListener implements Serializable {
LOG.trace( "Processing unreferenced collections" ); LOG.trace( "Processing unreferenced collections" );
Iterator<Map.Entry<PersistentCollection,CollectionEntry>> entriesIterator = IdentityMap.entriesIterator( persistenceContext.getCollectionEntries() ); for ( Map.Entry<PersistentCollection,CollectionEntry> me :
while ( entriesIterator.hasNext() ) { IdentityMap.entriesIterable( (Map<PersistentCollection,CollectionEntry>) persistenceContext.getCollectionEntries() )) {
Map.Entry<PersistentCollection,CollectionEntry> me = entriesIterator.next();
CollectionEntry ce = me.getValue(); CollectionEntry ce = me.getValue();
if ( !ce.isReached() && !ce.isIgnore() ) { if ( !ce.isReached() && !ce.isIgnore() ) {
Collections.processUnreachableCollection( me.getKey(), session ); Collections.processUnreachableCollection( me.getKey(), session );
@ -259,10 +257,9 @@ public abstract class AbstractFlushingEventListener implements Serializable {
LOG.trace( "Scheduling collection removes/(re)creates/updates" ); LOG.trace( "Scheduling collection removes/(re)creates/updates" );
entriesIterator = IdentityMap.entriesIterator( persistenceContext.getCollectionEntries() );
ActionQueue actionQueue = session.getActionQueue(); ActionQueue actionQueue = session.getActionQueue();
while ( entriesIterator.hasNext() ) { for ( Map.Entry<PersistentCollection,CollectionEntry> me :
Map.Entry<PersistentCollection,CollectionEntry> me = entriesIterator.next(); IdentityMap.entriesIterable( (Map<PersistentCollection,CollectionEntry>) persistenceContext.getCollectionEntries() )) {
PersistentCollection coll = me.getKey(); PersistentCollection coll = me.getKey();
CollectionEntry ce = me.getValue(); CollectionEntry ce = me.getValue();

View File

@ -90,8 +90,8 @@ public final class IdentityMap<K,V> implements Map<K,V> {
return ( (IdentityMap<K,V>) map ).entryArray(); return ( (IdentityMap<K,V>) map ).entryArray();
} }
public static <K,V> Iterator<Map.Entry<K,V>> entriesIterator(Map<K,V> map) { public static <K,V> Iterable<Map.Entry<K,V>> entriesIterable(Map<K,V> map) {
return ( (IdentityMap<K,V>) map ).entryList().iterator(); return ( (IdentityMap<K,V>) map ).entryList();
} }
public static <K,V> Iterator<K> keyIterator(Map<K,V> map) { public static <K,V> Iterator<K> keyIterator(Map<K,V> map) {