.clearSubselects(); //the database has changed now, so the subselect results need to be invalidated
for ( Map.Entry<PersistentCollection, CollectionEntry> me : IdentityMap.concurrentEntries( persistenceContext.getCollectionEntries() ) ) {
CollectionEntry collectionEntry = me.getValue();
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);