org.hibernate.proxy
Class AbstractLazyInitializer

java.lang.Object
  extended by org.hibernate.proxy.AbstractLazyInitializer
All Implemented Interfaces:
LazyInitializer
Direct Known Subclasses:
BasicLazyInitializer, Dom4jLazyInitializer, MapLazyInitializer

public abstract class AbstractLazyInitializer
extends Object
implements LazyInitializer

Convenience base class for lazy initialization handlers. Centralizes the basic plumbing of doing lazy initialization freeing subclasses to acts as essentially adapters to their intended entity mode and/or proxy generation strategy.

Author:
Gavin King

Constructor Summary
protected AbstractLazyInitializer(String entityName, Serializable id, SessionImplementor session)
           
 
Method Summary
 String getEntityName()
          Get the entity name
 Serializable getIdentifier()
          Get the identifier held by the proxy
 Object getImplementation()
          Return the underlying persistent object, initializing if necessary
 Object getImplementation(SessionImplementor s)
          Return the underlying persistent object in the given Session, or null, do not initialize the proxy
 SessionImplementor getSession()
          Get the session, if this proxy is attached
protected  Object getTarget()
           
 void initialize()
          Initialize the proxy, fetching the target entity if necessary
protected  boolean isConnectedToSession()
           
 boolean isUninitialized()
          Is the proxy uninitialzed?
 boolean isUnwrap()
           
 void setIdentifier(Serializable id)
          Set the identifier property of the proxy
 void setImplementation(Object target)
          Initialize the proxy manually
 void setSession(SessionImplementor s)
          Attach the proxy to a session
 void setUnwrap(boolean unwrap)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.hibernate.proxy.LazyInitializer
getPersistentClass
 

Constructor Detail

AbstractLazyInitializer

protected AbstractLazyInitializer(String entityName,
                                  Serializable id,
                                  SessionImplementor session)
Method Detail

getIdentifier

public final Serializable getIdentifier()
Description copied from interface: LazyInitializer
Get the identifier held by the proxy

Specified by:
getIdentifier in interface LazyInitializer

setIdentifier

public final void setIdentifier(Serializable id)
Description copied from interface: LazyInitializer
Set the identifier property of the proxy

Specified by:
setIdentifier in interface LazyInitializer

getEntityName

public final String getEntityName()
Description copied from interface: LazyInitializer
Get the entity name

Specified by:
getEntityName in interface LazyInitializer

isUninitialized

public final boolean isUninitialized()
Description copied from interface: LazyInitializer
Is the proxy uninitialzed?

Specified by:
isUninitialized in interface LazyInitializer

getSession

public final SessionImplementor getSession()
Description copied from interface: LazyInitializer
Get the session, if this proxy is attached

Specified by:
getSession in interface LazyInitializer

initialize

public final void initialize()
                      throws HibernateException
Description copied from interface: LazyInitializer
Initialize the proxy, fetching the target entity if necessary

Specified by:
initialize in interface LazyInitializer
Throws:
HibernateException

setSession

public final void setSession(SessionImplementor s)
                      throws HibernateException
Description copied from interface: LazyInitializer
Attach the proxy to a session

Specified by:
setSession in interface LazyInitializer
Throws:
HibernateException

isConnectedToSession

protected final boolean isConnectedToSession()

setImplementation

public final void setImplementation(Object target)
Description copied from interface: LazyInitializer
Initialize the proxy manually

Specified by:
setImplementation in interface LazyInitializer

getImplementation

public final Object getImplementation()
Return the underlying persistent object, initializing if necessary

Specified by:
getImplementation in interface LazyInitializer

getImplementation

public final Object getImplementation(SessionImplementor s)
                               throws HibernateException
Return the underlying persistent object in the given Session, or null, do not initialize the proxy

Specified by:
getImplementation in interface LazyInitializer
Throws:
HibernateException

getTarget

protected final Object getTarget()

isUnwrap

public boolean isUnwrap()
Specified by:
isUnwrap in interface LazyInitializer

setUnwrap

public void setUnwrap(boolean unwrap)
Specified by:
setUnwrap in interface LazyInitializer