public interface

LazyInitializer

org.hibernate.proxy.LazyInitializer
Known Indirect Subclasses

Class Overview

Handles fetching of the underlying entity for a proxy

Summary

Public Methods
abstract String getEntityName()
The entity-name of the entity our owning proxy represents.
abstract Serializable getIdentifier()
Retrieve the identifier value for the enity our owning proxy represents.
abstract Object getImplementation()
Return the underlying persistent object, initializing if necessary
abstract Object getImplementation(SessionImplementor session)
Return the underlying persistent object in the given session, or null if not contained in this session's persistence context.
abstract Class getPersistentClass()
Get the actual class of the entity.
abstract SessionImplementor getSession()
Get the session to which this proxy is associated, or null if it is not attached.
abstract void initialize()
Initialize the proxy, fetching the target entity if necessary.
abstract boolean isReadOnly()
Is the proxy read-only?.
abstract boolean isReadOnlySettingAvailable()
Is the proxy's read-only/modifiable setting available?
abstract boolean isUninitialized()
Is the proxy uninitialzed?
abstract boolean isUnwrap()
abstract void setIdentifier(Serializable id)
Set the identifier value for the enity our owning proxy represents.
abstract void setImplementation(Object target)
Initialize the proxy manually by injecting its target.
abstract void setReadOnly(boolean readOnly)
Set an associated modifiable proxy to read-only mode, or a read-only proxy to modifiable mode.
abstract void setSession(SessionImplementor session)
Associate the proxy with the given session.
abstract void setUnwrap(boolean unwrap)
abstract void unsetSession()
Unset this initializer's reference to session.

Public Methods

public abstract String getEntityName ()

The entity-name of the entity our owning proxy represents.

Returns
  • The entity-name.

public abstract Serializable getIdentifier ()

Retrieve the identifier value for the enity our owning proxy represents.

Returns
  • The identifier value.

public abstract Object getImplementation ()

Return the underlying persistent object, initializing if necessary

Returns
  • The underlying target entity.

public abstract Object getImplementation (SessionImplementor session)

Return the underlying persistent object in the given session, or null if not contained in this session's persistence context.

Parameters
session The session to check
Returns
  • The target, or null.
Throws
HibernateException Indicates problem locating the target.

public abstract Class getPersistentClass ()

Get the actual class of the entity. Generally, getEntityName() should be used instead.

Returns
  • The actual entity class.

public abstract SessionImplementor getSession ()

Get the session to which this proxy is associated, or null if it is not attached.

Returns
  • The associated session.

public abstract void initialize ()

Initialize the proxy, fetching the target entity if necessary.

Throws
HibernateException Indicates a problem initializing the proxy.

public abstract boolean isReadOnly ()

Is the proxy read-only?. The read-only/modifiable setting is not available when the proxy is detached or its associated session is closed. To check if the read-only/modifiable setting is available:

Returns
  • true, if this proxy is read-only; false, otherwise
Throws
TransientObjectException if the proxy is detached (getSession() == null)
SessionException if the proxy is associated with a sesssion that is closed

public abstract boolean isReadOnlySettingAvailable ()

Is the proxy's read-only/modifiable setting available?

Returns
  • true, if the setting is available false, if the proxy is detached or its associated session is closed

public abstract boolean isUninitialized ()

Is the proxy uninitialzed?

Returns
  • True if uninitialized; false otherwise.

public abstract boolean isUnwrap ()

public abstract void setIdentifier (Serializable id)

Set the identifier value for the enity our owning proxy represents.

Parameters
id The identifier value.

public abstract void setImplementation (Object target)

Initialize the proxy manually by injecting its target.

Parameters
target The proxy target (the actual entity being proxied).

public abstract void setReadOnly (boolean readOnly)

Set an associated modifiable proxy to read-only mode, or a read-only proxy to modifiable mode. If the proxy is currently initialized, its implementation will be set to the same mode; otherwise, when the proxy is initialized, its implementation will have the same read-only/ modifiable setting as the proxy. In read-only mode, no snapshot is maintained and the instance is never dirty checked. If the associated proxy already has the specified read-only/modifiable setting, then this method does nothing.

Throws
TransientObjectException if the proxy is not association with a session
SessionException if the proxy is associated with a sesssion that is closed

public abstract void setSession (SessionImplementor session)

Associate the proxy with the given session.

Care should be given to make certain that the proxy is added to the session's persistence context as well to maintain the symetry of the association. That must be done seperately as this method simply sets an internal reference. We do also check that if there is already an associated session that the proxy reference was removed from that previous session's persistence contet.

Parameters
session The session
Throws
HibernateException Indicates that the proxy was still contained in the persistence context of the "previous session".

public abstract void setUnwrap (boolean unwrap)

public abstract void unsetSession ()

Unset this initializer's reference to session. It is assumed that the caller is also taking care or cleaning up the owning proxy's reference in the persistence context.

Generally speaking this is intended to be called only during evict(Object) and clear() processing; most other use-cases should call setSession(SessionImplementor) instead.