FileDocCategorySizeDatePackage
EvictVisitor.javaAPI DocHibernate 3.2.52245Thu May 26 22:54:08 BST 2005org.hibernate.event.def

EvictVisitor

public class EvictVisitor extends AbstractVisitor
Evict any collections referenced by the object from the session cache. This will NOT pick up any collections that were dereferenced, so they will be deleted (suboptimal but not exactly incorrect).
author
Gavin King

Fields Summary
private static final Log
log
Constructors Summary
EvictVisitor(org.hibernate.event.EventSource session)


	  
		super(session);
	
Methods Summary
public voidevictCollection(java.lang.Object value, org.hibernate.type.CollectionType type)


		final Object pc;
		if ( type.hasHolder( getSession().getEntityMode() ) ) {
			pc = getSession().getPersistenceContext().removeCollectionHolder(value);
		}
		else if ( value instanceof PersistentCollection ) {
			pc = value;
		}
		else {
			return; //EARLY EXIT!
		}

		PersistentCollection collection = (PersistentCollection) pc;
		if ( collection.unsetSession( getSession() ) ) evictCollection(collection);
	
private voidevictCollection(org.hibernate.collection.PersistentCollection collection)

		CollectionEntry ce = (CollectionEntry) getSession().getPersistenceContext().getCollectionEntries().remove(collection);
		if ( log.isDebugEnabled() )
			log.debug(
					"evicting collection: " +
					MessageHelper.collectionInfoString( ce.getLoadedPersister(), ce.getLoadedKey(), getSession().getFactory() )
			);
		if ( ce.getLoadedPersister() != null && ce.getLoadedKey() != null ) {
			//TODO: is this 100% correct?
			getSession().getPersistenceContext().getCollectionsByKey().remove( 
					new CollectionKey( ce.getLoadedPersister(), ce.getLoadedKey(), getSession().getEntityMode() ) 
			);
		}
	
java.lang.ObjectprocessCollection(java.lang.Object collection, org.hibernate.type.CollectionType type)


		if (collection!=null) evictCollection(collection, type);

		return null;