Iterator iter = persistenceContext.getCollectionEntries().entrySet().iterator();
while ( iter.hasNext() ) {
Map.Entry me = (Map.Entry) iter.next();
CollectionEntry collectionEntry = (CollectionEntry) me.getValue();
PersistentCollection persistentCollection = (PersistentCollection) me.getKey();
collectionEntry.postFlush(persistentCollection);
if ( collectionEntry.getLoadedPersister() == null ) {
//if the collection is dereferenced, remove from the session cache
//iter.remove(); //does not work, since the entrySet is not backed by the set
persistenceContext.getCollectionEntries()
.remove(persistentCollection);