类 AbstractLazyInitializer
- java.lang.Object
-
- org.hibernate.proxy.AbstractLazyInitializer
-
- 所有已实现的接口:
LazyInitializer
- 直接已知子类:
BasicLazyInitializer,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.- 作者:
- Gavin King
-
-
构造器概要
构造器 限定符 构造器 说明 protectedAbstractLazyInitializer()已过时。This constructor was initially intended for serialization only, and is not useful anymore.protectedAbstractLazyInitializer(String entityName, Serializable id, SharedSessionContractImplementor session)Main constructor.
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 StringgetEntityName()The entity-name of the entity our owning proxy represents.SerializablegetIdentifier()Retrieve the identifier value for the entity our owning proxy represents.ObjectgetImplementation()Return the underlying persistent object, initializing if necessaryObjectgetImplementation(SharedSessionContractImplementor s)Return the underlying persistent object in the given session, or null if not contained in this session's persistence context.SharedSessionContractImplementorgetSession()Get the session to which this proxy is associated, or null if it is not attached.protected StringgetSessionFactoryUuid()Get the session factory UUID.protected ObjectgetTarget()Getter for property 'target'.voidinitialize()Initialize the proxy, fetching the target entity if necessary.voidinitializeWithoutLoadIfPossible()Attempt to initialize the proxy without loading anything from the database.protected booleanisAllowLoadOutsideTransaction()Get whether the proxy can load data even if it's not attached to a session with an ongoing transaction.protected booleanisConnectedToSession()Getter for property 'connectedToSession'.booleanisReadOnly()Is the proxy read-only?BooleanisReadOnlyBeforeAttachedToSession()Get the read-only/modifiable setting that should be put in affect when it is attached to a session.booleanisReadOnlySettingAvailable()Is the proxy's read-only/modifiable setting available?booleanisUninitialized()Is the proxy uninitialized?booleanisUnwrap()protected voidpermissiveInitialization()protected voidprepareForPossibleLoadingOutsideTransaction()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.voidsetIdentifier(Serializable id)Set the identifier value for the entity our owning proxy represents.voidsetImplementation(Object target)Initialize the proxy manually by injecting its target.voidsetReadOnly(boolean readOnly)Set an associated modifiable proxy to read-only mode, or a read-only proxy to modifiable mode.voidsetSession(SharedSessionContractImplementor s)Associate the proxy with the given session.voidsetUnwrap(boolean unwrap)voidunsetSession()Unset this initializer's reference to session.-
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
从接口继承的方法 org.hibernate.proxy.LazyInitializer
getPersistentClass
-
-
-
-
构造器详细资料
-
AbstractLazyInitializer
@Deprecated protected AbstractLazyInitializer()
已过时。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 anObject writeReplace()method returning a subclass ofAbstractSerializableProxy, which in turn implements Serializable and anObject readResolve()method instantiating theAbstractLazyInitializersubclass and callingAbstractSerializableProxy.afterDeserialization(AbstractLazyInitializer)on it. SeeByteBuddyInterceptorandSerializableProxyfor examples.
-
AbstractLazyInitializer
protected AbstractLazyInitializer(String entityName, Serializable id, SharedSessionContractImplementor session)
Main constructor.- 参数:
entityName- The name of the entity being proxied.id- The identifier of the entity being proxied.session- The session owning the proxy.
-
-
方法详细资料
-
getEntityName
public final String getEntityName()
从接口复制的说明:LazyInitializerThe entity-name of the entity our owning proxy represents.- 指定者:
getEntityName在接口中LazyInitializer- 返回:
- The entity-name.
-
getIdentifier
public final Serializable getIdentifier()
从接口复制的说明:LazyInitializerRetrieve the identifier value for the entity our owning proxy represents.- 指定者:
getIdentifier在接口中LazyInitializer- 返回:
- The identifier value.
-
setIdentifier
public final void setIdentifier(Serializable id)
从接口复制的说明:LazyInitializerSet the identifier value for the entity our owning proxy represents.- 指定者:
setIdentifier在接口中LazyInitializer- 参数:
id- The identifier value.
-
isUninitialized
public final boolean isUninitialized()
从接口复制的说明:LazyInitializerIs the proxy uninitialized?- 指定者:
isUninitialized在接口中LazyInitializer- 返回:
- True if uninitialized; false otherwise.
-
getSession
public final SharedSessionContractImplementor getSession()
从接口复制的说明:LazyInitializerGet the session to which this proxy is associated, or null if it is not attached.- 指定者:
getSession在接口中LazyInitializer- 返回:
- The associated session.
-
setSession
public final void setSession(SharedSessionContractImplementor s) throws HibernateException
从接口复制的说明:LazyInitializerAssociate 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 symmetry of the association. That must be done separately 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 context.- 指定者:
setSession在接口中LazyInitializer- 参数:
s- The session- 抛出:
HibernateException- Indicates that the proxy was still contained in the persistence context of the "previous session".
-
unsetSession
public final void unsetSession()
从接口复制的说明:LazyInitializerUnset 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 duringSession.evict(java.lang.Object)andSession.clear()processing; most other use-cases should callLazyInitializer.setSession(org.hibernate.engine.spi.SharedSessionContractImplementor)instead.- 指定者:
unsetSession在接口中LazyInitializer
-
initialize
public final void initialize() throws HibernateException从接口复制的说明:LazyInitializerInitialize the proxy, fetching the target entity if necessary.- 指定者:
initialize在接口中LazyInitializer- 抛出:
HibernateException- Indicates a problem initializing the proxy.
-
permissiveInitialization
protected void permissiveInitialization()
-
initializeWithoutLoadIfPossible
public final void initializeWithoutLoadIfPossible()
Attempt to initialize the proxy without loading anything from the database. This will only have any effect if the proxy is still attached to a session, and the entity being proxied has been loaded and added to the persistence context of that session since the proxy was created.
-
prepareForPossibleLoadingOutsideTransaction
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. This method only has any effect ifSessionFactoryOptions.isInitializeLazyStateOutsideTransactionsEnabled()istrue.
-
isConnectedToSession
protected final boolean isConnectedToSession()
Getter for property 'connectedToSession'.- 返回:
- Value for property 'connectedToSession'.
-
getImplementation
public final Object getImplementation()
从接口复制的说明:LazyInitializerReturn the underlying persistent object, initializing if necessary- 指定者:
getImplementation在接口中LazyInitializer- 返回:
- The underlying target entity.
-
setImplementation
public final void setImplementation(Object target)
从接口复制的说明:LazyInitializerInitialize the proxy manually by injecting its target.- 指定者:
setImplementation在接口中LazyInitializer- 参数:
target- The proxy target (the actual entity being proxied).
-
getImplementation
public final Object getImplementation(SharedSessionContractImplementor s) throws HibernateException
从接口复制的说明:LazyInitializerReturn the underlying persistent object in the given session, or null if not contained in this session's persistence context.- 指定者:
getImplementation在接口中LazyInitializer- 参数:
s- The session to check- 返回:
- The target, or null.
- 抛出:
HibernateException- Indicates problem locating the target.
-
getTarget
protected final Object getTarget()
Getter for property 'target'. Same asgetImplementation()except that this method will not force initialization.- 返回:
- Value for property 'target'.
-
isReadOnlySettingAvailable
public final boolean isReadOnlySettingAvailable()
从接口复制的说明:LazyInitializerIs the proxy's read-only/modifiable setting available?- 指定者:
isReadOnlySettingAvailable在接口中LazyInitializer- 返回:
- true, if the setting is available false, if the proxy is detached or its associated session is closed
-
isReadOnly
public final boolean isReadOnly()
从接口复制的说明:LazyInitializerIs 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:- 指定者:
isReadOnly在接口中LazyInitializer- 返回:
- true, if this proxy is read-only; false, otherwise
- 另请参阅:
LazyInitializer.isReadOnlySettingAvailable(),Session.isReadOnly(Object entityOrProxy)
-
setReadOnly
public final void setReadOnly(boolean readOnly)
从接口复制的说明:LazyInitializerSet 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.- 指定者:
setReadOnly在接口中LazyInitializer- 参数:
readOnly- if true, the associated proxy is made read-only; if false, the associated proxy is made modifiable.- 另请参阅:
Session.setReadOnly(Object entityOrProxy, boolean readOnly)
-
isReadOnlyBeforeAttachedToSession
public final Boolean isReadOnlyBeforeAttachedToSession()
Get the read-only/modifiable setting that should be put in affect when it is attached to a session. This method should only be called during serialization when read-only/modifiable setting is not available (i.e., isReadOnlySettingAvailable() == false)- 返回:
- null, if the default setting should be used; true, for read-only; false, for modifiable
- 抛出:
IllegalStateException- if isReadOnlySettingAvailable() == true
-
isAllowLoadOutsideTransaction
protected boolean isAllowLoadOutsideTransaction()
Get whether the proxy can load data even if it's not attached to a session with an ongoing transaction. This method should only be called during serialization, and only makes sense after a call toprepareForPossibleLoadingOutsideTransaction().- 返回:
trueif out-of-transaction loads are allowed,falseotherwise.
-
getSessionFactoryUuid
protected String getSessionFactoryUuid()
Get the session factory UUID. This method should only be called during serialization, and only makes sense after a call toprepareForPossibleLoadingOutsideTransaction().- 返回:
- the session factory UUID.
-
isUnwrap
public boolean isUnwrap()
- 指定者:
isUnwrap在接口中LazyInitializer
-
setUnwrap
public void setUnwrap(boolean unwrap)
- 指定者:
setUnwrap在接口中LazyInitializer
-
-