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 java.lang.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(java.lang.String entityName, java.io.Serializable id, SessionImplementor session)
           
 
Method Summary
 java.lang.String getEntityName()
          Get the entity name
 java.io.Serializable getIdentifier()
          Get the identifier held by the proxy
 java.lang.Object getImplementation()
          Return the underlying persistent object, initializing if necessary
 java.lang.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  java.lang.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(java.io.Serializable id)
          Set the identifier property of the proxy
 void setImplementation(java.lang.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(java.lang.String entityName,
                                  java.io.Serializable id,
                                  SessionImplementor session)
Method Detail

getIdentifier

public final java.io.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(java.io.Serializable id)
Description copied from interface: LazyInitializer
Set the identifier property of the proxy

Specified by:
setIdentifier in interface LazyInitializer

getEntityName

public final java.lang.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(java.lang.Object target)
Description copied from interface: LazyInitializer
Initialize the proxy manually

Specified by:
setImplementation in interface LazyInitializer

getImplementation

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

Specified by:
getImplementation in interface LazyInitializer

getImplementation

public final java.lang.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 java.lang.Object getTarget()

isUnwrap

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

setUnwrap

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


Copyright © 2008 Hibernate.org. All Rights Reserved.