FileDocCategorySizeDatePackage
ProxyVisitor.javaAPI DocHibernate 3.2.52464Fri Jun 17 14:36:08 BST 2005org.hibernate.event.def

ProxyVisitor

public abstract class ProxyVisitor extends AbstractVisitor
Reassociates uninitialized proxies with the session
author
Gavin King

Fields Summary
Constructors Summary
public ProxyVisitor(org.hibernate.event.EventSource session)

		super(session);
	
Methods Summary
private static booleanisCollectionSnapshotValid(org.hibernate.collection.PersistentCollection snapshot)

		return snapshot != null &&
				snapshot.getRole() != null &&
				snapshot.getKey() != null;
	
protected static booleanisOwnerUnchanged(org.hibernate.collection.PersistentCollection snapshot, org.hibernate.persister.collection.CollectionPersister persister, java.io.Serializable id)
Has the owner of the collection changed since the collection was snapshotted and detached?

		return isCollectionSnapshotValid(snapshot) &&
				persister.getRole().equals( snapshot.getRole() ) &&
				id.equals( snapshot.getKey() );
	
java.lang.ObjectprocessEntity(java.lang.Object value, org.hibernate.type.EntityType entityType)


		if (value!=null) {
			getSession().getPersistenceContext().reassociateIfUninitializedProxy(value);
			// if it is an initialized proxy, let cascade
			// handle it later on
		}

		return null;
	
protected voidreattachCollection(org.hibernate.collection.PersistentCollection collection, org.hibernate.type.CollectionType type)
Reattach a detached (disassociated) initialized or uninitialized collection wrapper, using a snapshot carried with the collection wrapper

		if ( collection.wasInitialized() ) {
			CollectionPersister collectionPersister = getSession().getFactory()
			.getCollectionPersister( type.getRole() );
			getSession().getPersistenceContext()
				.addInitializedDetachedCollection( collectionPersister, collection );
		}
		else {
			if ( !isCollectionSnapshotValid(collection) ) {
				throw new HibernateException( "could not reassociate uninitialized transient collection" );
			}
			CollectionPersister collectionPersister = getSession().getFactory()
					.getCollectionPersister( collection.getRole() );
			getSession().getPersistenceContext()
				.addUninitializedDetachedCollection( collectionPersister, collection );
		}