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
|
//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.entries(entityEntries).iterator();
|
Iterator<Entry<Object,EntityEntry>> entities = IdentityMap.entriesIterator( entityEntries );
|
||||||
while ( entities.hasNext() ) {
|
while ( entities.hasNext() ) {
|
||||||
final Map.Entry<Object,EntityEntry> me = entities.next();
|
final Map.Entry<Object,EntityEntry> me = entities.next();
|
||||||
final EntityEntry entityEntry = me.getValue();
|
final EntityEntry entityEntry = me.getValue();
|
||||||
|
@ -1286,7 +1286,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Not found in cache, proceed
|
//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() ) {
|
while ( entities.hasNext() ) {
|
||||||
Map.Entry<Object,EntityEntry> me = entities.next();
|
Map.Entry<Object,EntityEntry> me = entities.next();
|
||||||
EntityEntry ee = me.getValue();
|
EntityEntry ee = me.getValue();
|
||||||
|
|
|
@ -25,7 +25,6 @@ package org.hibernate.event.internal;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
@ -187,11 +186,10 @@ public abstract class AbstractFlushingEventListener implements Serializable {
|
||||||
|
|
||||||
LOG.debug( "Dirty checking collections" );
|
LOG.debug( "Dirty checking collections" );
|
||||||
|
|
||||||
final List list = IdentityMap.entries( persistenceContext.getCollectionEntries() );
|
Iterator<Map.Entry<PersistentCollection,CollectionEntry>> entriesIterator = IdentityMap.entriesIterator( persistenceContext.getCollectionEntries() );
|
||||||
final int size = list.size();
|
while ( entriesIterator.hasNext() ) {
|
||||||
for ( int i = 0; i < size; i++ ) {
|
Map.Entry<PersistentCollection,CollectionEntry> e = entriesIterator.next();
|
||||||
Map.Entry e = ( Map.Entry ) list.get( i );
|
e.getValue().preFlush( e.getKey() );
|
||||||
( (CollectionEntry) e.getValue() ).preFlush( (PersistentCollection) e.getKey() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,13 +246,12 @@ public abstract class AbstractFlushingEventListener implements Serializable {
|
||||||
|
|
||||||
LOG.trace( "Processing unreferenced collections" );
|
LOG.trace( "Processing unreferenced collections" );
|
||||||
|
|
||||||
List list = IdentityMap.entries( persistenceContext.getCollectionEntries() );
|
Iterator<Map.Entry<PersistentCollection,CollectionEntry>> entriesIterator = IdentityMap.entriesIterator( persistenceContext.getCollectionEntries() );
|
||||||
int size = list.size();
|
while ( entriesIterator.hasNext() ) {
|
||||||
for ( int i = 0; i < size; i++ ) {
|
Map.Entry<PersistentCollection,CollectionEntry> me = entriesIterator.next();
|
||||||
Map.Entry me = ( Map.Entry ) list.get( i );
|
CollectionEntry ce = me.getValue();
|
||||||
CollectionEntry ce = (CollectionEntry) me.getValue();
|
|
||||||
if ( !ce.isReached() && !ce.isIgnore() ) {
|
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" );
|
LOG.trace( "Scheduling collection removes/(re)creates/updates" );
|
||||||
|
|
||||||
list = IdentityMap.entries( persistenceContext.getCollectionEntries() );
|
entriesIterator = IdentityMap.entriesIterator( persistenceContext.getCollectionEntries() );
|
||||||
size = list.size();
|
|
||||||
ActionQueue actionQueue = session.getActionQueue();
|
ActionQueue actionQueue = session.getActionQueue();
|
||||||
for ( int i = 0; i < size; i++ ) {
|
while ( entriesIterator.hasNext() ) {
|
||||||
Map.Entry me = (Map.Entry) list.get(i);
|
Map.Entry<PersistentCollection,CollectionEntry> me = entriesIterator.next();
|
||||||
PersistentCollection coll = (PersistentCollection) me.getKey();
|
PersistentCollection coll = me.getKey();
|
||||||
CollectionEntry ce = (CollectionEntry) me.getValue();
|
CollectionEntry ce = me.getValue();
|
||||||
|
|
||||||
if ( ce.isDorecreate() ) {
|
if ( ce.isDorecreate() ) {
|
||||||
session.getInterceptor().onCollectionRecreate( coll, ce.getCurrentKey() );
|
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();
|
return ( (IdentityMap<K,V>) map ).entryArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <K,V> List<Entry<K,V>> entries(Map<K,V> map) {
|
public static <K,V> Iterator<Map.Entry<K,V>> entriesIterator(Map<K,V> map) {
|
||||||
return ( (IdentityMap<K,V>) map ).entryList();
|
return ( (IdentityMap<K,V>) map ).entryList().iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <K,V> Iterator<K> keyIterator(Map<K,V> map) {
|
public static <K,V> Iterator<K> keyIterator(Map<K,V> map) {
|
||||||
|
|
Loading…
Reference in New Issue