/**
  * Remove a proxy from the session cache.
  *
  * <p>Additionally, ensure that any load optimization references such as batch or subselect
  * loading get cleaned up as well.
  *
  * @param key The key of the entity proxy to be removed
  * @return The proxy reference.
  */
 public Object removeProxy(EntityKey key) {
   if (batchFetchQueue != null) {
     batchFetchQueue.removeBatchLoadableEntityKey(key);
     batchFetchQueue.removeSubselect(key);
   }
   return proxiesByKey.remove(key);
 }
 public void clear() {
   arrayHolders.clear();
   entitiesByKey.clear();
   entitiesByUniqueKey.clear();
   entityEntries.clear();
   entitySnapshotsByKey.clear();
   collectionsByKey.clear();
   collectionEntries.clear();
   if (unownedCollections != null) {
     unownedCollections.clear();
   }
   proxiesByKey.clear();
   nullifiableEntityKeys.clear();
   if (batchFetchQueue != null) {
     batchFetchQueue.clear();
   }
   hasNonReadOnlyEntities = false;
 }