public abstract class AbstractLazyInitializer extends Object implements LazyInitializer
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractLazyInitializer()
Deprecated.
This constructor was initially intended for serialization only, and is not useful anymore.
In any case it should not be relied on by user code.
Subclasses should rather implement Serializable with an
Object writeReplace() method returning
a subclass of AbstractSerializableProxy,
which in turn implements Serializable and an Object readResolve() method
instantiating the AbstractLazyInitializer subclass
and calling AbstractSerializableProxy.afterDeserialization(AbstractLazyInitializer) on it.
See ByteBuddyInterceptor and
SerializableProxy for examples. |
protected |
AbstractLazyInitializer(String entityName,
Serializable id,
SharedSessionContractImplementor session)
Main constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getEntityName()
The entity-name of the entity our owning proxy represents.
|
Serializable |
getIdentifier()
Retrieve the identifier value for the entity our owning proxy represents.
|
Object |
getImplementation()
Return the underlying persistent object, initializing if necessary
|
Object |
getImplementation(SharedSessionContractImplementor s)
Return the underlying persistent object in the given session, or null if not contained in this session's
persistence context.
|
Serializable |
getInternalIdentifier()
Retrieve the identifier value for the entity our owning proxy represents.
|
SharedSessionContractImplementor |
getSession()
Get the session to which this proxy is associated, or null if it is not attached.
|
protected String |
getSessionFactoryUuid()
Get the session factory UUID.
|
protected Object |
getTarget()
Getter for property 'target'.
|
void |
initialize()
Initialize the proxy, fetching the target entity if necessary.
|
void |
initializeWithoutLoadIfPossible()
Attempt to initialize the proxy without loading anything from the database.
|
protected boolean |
isAllowLoadOutsideTransaction()
Get whether the proxy can load data even
if it's not attached to a session with an ongoing transaction.
|
protected boolean |
isConnectedToSession()
Getter for property 'connectedToSession'.
|
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.
|
Boolean |
isReadOnlyBeforeAttachedToSession()
Get the read-only/modifiable setting that should be put in affect when it is
attached to a session.
|
boolean |
isReadOnlySettingAvailable()
Is the proxy's read-only/modifiable setting available?
|
boolean |
isUninitialized()
Is the proxy uninitialized?
|
boolean |
isUnwrap() |
protected void |
permissiveInitialization() |
protected void |
prepareForPossibleLoadingOutsideTransaction()
Initialize internal state based on the currently attached session,
in order to be ready to load data even after the proxy is detached from the session.
|
void |
setIdentifier(Serializable id)
Set the identifier value for the entity our owning proxy represents.
|
void |
setImplementation(Object target)
Initialize the proxy manually by injecting its target.
|
void |
setReadOnly(boolean readOnly)
Set an associated modifiable proxy to read-only mode, or a read-only
proxy to modifiable mode.
|
void |
setSession(SharedSessionContractImplementor s)
Associate the proxy with the given session.
|
void |
setUnwrap(boolean unwrap) |
void |
unsetSession()
Unset this initializer's reference to session.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetPersistentClass@Deprecated protected AbstractLazyInitializer()
Object writeReplace() method returning
a subclass of AbstractSerializableProxy,
which in turn implements Serializable and an Object readResolve() method
instantiating the AbstractLazyInitializer subclass
and calling AbstractSerializableProxy.afterDeserialization(AbstractLazyInitializer) on it.
See ByteBuddyInterceptor and
SerializableProxy for examples.protected AbstractLazyInitializer(String entityName, Serializable id, SharedSessionContractImplementor session)
entityName - The name of the entity being proxied.id - The identifier of the entity being proxied.session - The session owning the proxy.public final String getEntityName()
LazyInitializergetEntityName in interface LazyInitializerpublic final Serializable getInternalIdentifier()
LazyInitializergetInternalIdentifier in interface LazyInitializerpublic final Serializable getIdentifier()
LazyInitializergetIdentifier in interface LazyInitializerpublic final void setIdentifier(Serializable id)
LazyInitializersetIdentifier in interface LazyInitializerid - The identifier value.public final boolean isUninitialized()
LazyInitializerisUninitialized in interface LazyInitializerpublic final SharedSessionContractImplementor getSession()
LazyInitializergetSession in interface LazyInitializerpublic final void setSession(SharedSessionContractImplementor s) throws HibernateException
LazyInitializersetSession in interface LazyInitializers - The sessionHibernateException - Indicates that the proxy was still contained in the persistence context of the
"previous session".public final void unsetSession()
LazyInitializerSession.evict(java.lang.Object) and
Session.clear() processing; most other use-cases should call LazyInitializer.setSession(org.hibernate.engine.spi.SharedSessionContractImplementor) instead.unsetSession in interface LazyInitializerpublic final void initialize()
throws HibernateException
LazyInitializerinitialize in interface LazyInitializerHibernateException - Indicates a problem initializing the proxy.protected void permissiveInitialization()
public final void initializeWithoutLoadIfPossible()
protected void prepareForPossibleLoadingOutsideTransaction()
SessionFactoryOptions.isInitializeLazyStateOutsideTransactionsEnabled() is true.protected final boolean isConnectedToSession()
public final Object getImplementation()
LazyInitializergetImplementation in interface LazyInitializerpublic final void setImplementation(Object target)
LazyInitializersetImplementation in interface LazyInitializertarget - The proxy target (the actual entity being proxied).public final Object getImplementation(SharedSessionContractImplementor s) throws HibernateException
LazyInitializergetImplementation in interface LazyInitializers - The session to checkHibernateException - Indicates problem locating the target.protected final Object getTarget()
getImplementation() except that this method will not force initialization.public final boolean isReadOnlySettingAvailable()
LazyInitializerisReadOnlySettingAvailable in interface LazyInitializerpublic final boolean isReadOnly()
LazyInitializerisReadOnly in interface LazyInitializerLazyInitializer.isReadOnlySettingAvailable(),
Session.isReadOnly(Object entityOrProxy)public final void setReadOnly(boolean readOnly)
LazyInitializersetReadOnly in interface LazyInitializerreadOnly - if true, the associated proxy is made read-only;
if false, the associated proxy is made modifiable.Session.setReadOnly(Object entityOrProxy, boolean readOnly)public final Boolean isReadOnlyBeforeAttachedToSession()
IllegalStateException - if isReadOnlySettingAvailable() == trueprotected boolean isAllowLoadOutsideTransaction()
prepareForPossibleLoadingOutsideTransaction().true if out-of-transaction loads are allowed, false otherwise.protected String getSessionFactoryUuid()
prepareForPossibleLoadingOutsideTransaction().public boolean isUnwrap()
isUnwrap in interface LazyInitializerpublic void setUnwrap(boolean unwrap)
setUnwrap in interface LazyInitializerCopyright © 2001-2022 Red Hat, Inc. All Rights Reserved.