HHH-6862 Improve API of IdentityMap helpers to match actual use cases
This commit is contained in:
parent
67d1c70335
commit
aa4954be8b
|
@ -1162,7 +1162,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
|||
|
||||
//not found in case, proceed
|
||||
// iterate all the entities currently associated with the persistence context.
|
||||
Iterator<Entry<Object,EntityEntry>> entities = IdentityMap.entries(entityEntries).iterator();
|
||||
Iterator<Entry<Object,EntityEntry>> entities = IdentityMap.entriesIterator( entityEntries );
|
||||
while ( entities.hasNext() ) {
|
||||
final Map.Entry<Object,EntityEntry> me = entities.next();
|
||||
final EntityEntry entityEntry = me.getValue();
|
||||
|
@ -1286,7 +1286,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
|||
}
|
||||
|
||||
//Not found in cache, proceed
|
||||
Iterator<Entry<Object,EntityEntry>> entities = IdentityMap.entries(entityEntries).iterator();
|
||||
Iterator<Entry<Object,EntityEntry>> entities = IdentityMap.entriesIterator( entityEntries );
|
||||
while ( entities.hasNext() ) {
|
||||
Map.Entry<Object,EntityEntry> me = entities.next();
|
||||
EntityEntry ee = me.getValue();
|
||||
|
|
|
@ -25,7 +25,6 @@ package org.hibernate.event.internal;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
@ -187,11 +186,10 @@ public abstract class AbstractFlushingEventListener implements Serializable {
|
|||
|
||||
LOG.debug( "Dirty checking collections" );
|
||||
|
||||
final List list = IdentityMap.entries( persistenceContext.getCollectionEntries() );
|
||||
final int size = list.size();
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
Map.Entry e = ( Map.Entry ) list.get( i );
|
||||
( (CollectionEntry) e.getValue() ).preFlush( (PersistentCollection) e.getKey() );
|
||||
Iterator<Map.Entry<PersistentCollection,CollectionEntry>> entriesIterator = IdentityMap.entriesIterator( persistenceContext.getCollectionEntries() );
|
||||
while ( entriesIterator.hasNext() ) {
|
||||
Map.Entry<PersistentCollection,CollectionEntry> e = entriesIterator.next();
|
||||
e.getValue().preFlush( e.getKey() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,13 +246,12 @@ public abstract class AbstractFlushingEventListener implements Serializable {
|
|||
|
||||
LOG.trace( "Processing unreferenced collections" );
|
||||
|
||||
List list = IdentityMap.entries( persistenceContext.getCollectionEntries() );
|
||||
int size = list.size();
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
Map.Entry me = ( Map.Entry ) list.get( i );
|
||||
CollectionEntry ce = (CollectionEntry) me.getValue();
|
||||
Iterator<Map.Entry<PersistentCollection,CollectionEntry>> entriesIterator = IdentityMap.entriesIterator( persistenceContext.getCollectionEntries() );
|
||||
while ( entriesIterator.hasNext() ) {
|
||||
Map.Entry<PersistentCollection,CollectionEntry> me = entriesIterator.next();
|
||||
CollectionEntry ce = me.getValue();
|
||||
if ( !ce.isReached() && !ce.isIgnore() ) {
|
||||
Collections.processUnreachableCollection( (PersistentCollection) me.getKey(), session );
|
||||
Collections.processUnreachableCollection( me.getKey(), session );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,13 +259,12 @@ public abstract class AbstractFlushingEventListener implements Serializable {
|
|||
|
||||
LOG.trace( "Scheduling collection removes/(re)creates/updates" );
|
||||
|
||||
list = IdentityMap.entries( persistenceContext.getCollectionEntries() );
|
||||
size = list.size();
|
||||
entriesIterator = IdentityMap.entriesIterator( persistenceContext.getCollectionEntries() );
|
||||
ActionQueue actionQueue = session.getActionQueue();
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
Map.Entry me = (Map.Entry) list.get(i);
|
||||
PersistentCollection coll = (PersistentCollection) me.getKey();
|
||||
CollectionEntry ce = (CollectionEntry) me.getValue();
|
||||
while ( entriesIterator.hasNext() ) {
|
||||
Map.Entry<PersistentCollection,CollectionEntry> me = entriesIterator.next();
|
||||
PersistentCollection coll = me.getKey();
|
||||
CollectionEntry ce = me.getValue();
|
||||
|
||||
if ( ce.isDorecreate() ) {
|
||||
session.getInterceptor().onCollectionRecreate( coll, ce.getCurrentKey() );
|
||||
|
|
|
@ -90,8 +90,8 @@ public final class IdentityMap<K,V> implements Map<K,V> {
|
|||
return ( (IdentityMap<K,V>) map ).entryArray();
|
||||
}
|
||||
|
||||
public static <K,V> List<Entry<K,V>> entries(Map<K,V> map) {
|
||||
return ( (IdentityMap<K,V>) map ).entryList();
|
||||
public static <K,V> Iterator<Map.Entry<K,V>> entriesIterator(Map<K,V> map) {
|
||||
return ( (IdentityMap<K,V>) map ).entryList().iterator();
|
||||
}
|
||||
|
||||
public static <K,V> Iterator<K> keyIterator(Map<K,V> map) {
|
||||
|
|
Loading…
Reference in New Issue