FileDocCategorySizeDatePackage
AbstractFieldInterceptor.javaAPI DocHibernate 3.2.52576Fri Feb 03 15:15:20 GMT 2006org.hibernate.intercept

AbstractFieldInterceptor

public abstract class AbstractFieldInterceptor extends Object implements Serializable, FieldInterceptor
author
Steve Ebersole

Fields Summary
private transient org.hibernate.engine.SessionImplementor
session
private Set
uninitializedFields
private final String
entityName
private transient boolean
initializing
private boolean
dirty
Constructors Summary
protected AbstractFieldInterceptor(org.hibernate.engine.SessionImplementor session, Set uninitializedFields, String entityName)

		this.session = session;
		this.uninitializedFields = uninitializedFields;
		this.entityName = entityName;
	
Methods Summary
public final voidclearDirty()

		dirty = false;
	
public final voiddirty()

		dirty = true;
	
public final java.lang.StringgetEntityName()

		return entityName;
	
public final org.hibernate.engine.SessionImplementorgetSession()

		return session;
	
public final java.util.SetgetUninitializedFields()

		return uninitializedFields;
	
protected final java.lang.Objectintercept(java.lang.Object target, java.lang.String fieldName, java.lang.Object value)

		if ( initializing ) {
			return value;
		}

		if ( uninitializedFields != null && uninitializedFields.contains( fieldName ) ) {
			if ( session == null ) {
				throw new LazyInitializationException( "entity with lazy properties is not associated with a session" );
			}
			else if ( !session.isOpen() || !session.isConnected() ) {
				throw new LazyInitializationException( "session is not connected" );
			}

			final Object result;
			initializing = true;
			try {
				result = ( ( LazyPropertyInitializer ) session.getFactory()
						.getEntityPersister( entityName ) )
						.initializeLazyProperty( fieldName, target, session );
			}
			finally {
				initializing = false;
			}
			uninitializedFields = null; //let's assume that there is only one lazy fetch group, for now!
			return result;
		}
		else {
			return value;
		}
	
public final booleanisDirty()

		return dirty;
	
public final booleanisInitialized()

		return uninitializedFields == null || uninitializedFields.size() == 0;
	
public final booleanisInitialized(java.lang.String field)

		return uninitializedFields == null || !uninitializedFields.contains( field );
	
public final booleanisInitializing()

		return initializing;
	
public final voidsetSession(org.hibernate.engine.SessionImplementor session)

		this.session = session;