FileDocCategorySizeDatePackage
ReattachVisitor.javaAPI DocHibernate 3.2.53095Thu Dec 07 14:53:42 GMT 2006org.hibernate.event.def

ReattachVisitor

public abstract class ReattachVisitor extends ProxyVisitor
Abstract superclass of visitors that reattach collections.
author
Gavin King

Fields Summary
private static final Log
log
private final Serializable
ownerIdentifier
private final Object
owner
Constructors Summary
public ReattachVisitor(org.hibernate.event.EventSource session, Serializable ownerIdentifier, Object owner)


	       
		super( session );
		this.ownerIdentifier = ownerIdentifier;
		this.owner = owner;
	
Methods Summary
final java.io.SerializableextractCollectionKeyFromOwner(org.hibernate.persister.collection.CollectionPersister role)
This version is slightly different in that here we need to assume that the owner is not yet associated with the session, and thus we cannot rely on the owner's EntityEntry snapshot...

param
role The persister for the collection role being processed.
return

		if ( role.getCollectionType().useLHSPrimaryKey() ) {
			return ownerIdentifier;
		}
		else {
			return ( Serializable ) role.getOwnerEntityPersister().getPropertyValue( owner, role.getCollectionType().getLHSPropertyName(), getSession().getEntityMode() );
		}

	
final java.lang.ObjectgetOwner()
Retrieve the entity being visited.

return
The entity.

		return owner;
	
final java.io.SerializablegetOwnerIdentifier()
Retrieve the identifier of the entity being visited.

return
The entity's identifier.

		return ownerIdentifier;
	
java.lang.ObjectprocessComponent(java.lang.Object component, org.hibernate.type.AbstractComponentType componentType)
{@inheritDoc}

		Type[] types = componentType.getSubtypes();
		if ( component == null ) {
			processValues( new Object[types.length], types );
		}
		else {
			super.processComponent( component, componentType );
		}

		return null;
	
voidremoveCollection(org.hibernate.persister.collection.CollectionPersister role, java.io.Serializable collectionKey, org.hibernate.event.EventSource source)
Schedules a collection for deletion.

param
role The persister representing the collection to be removed.
param
collectionKey The collection key (differs from owner-id in the case of property-refs).
param
source The session from which the request originated.
throws
HibernateException

		if ( log.isTraceEnabled() ) {
			log.trace(
					"collection dereferenced while transient " +
					MessageHelper.collectionInfoString( role, ownerIdentifier, source.getFactory() )
			);
		}
		source.getActionQueue().addAction( new CollectionRemoveAction( null, role, collectionKey, false, source ) );