Interface LazyInitializer

    • Method Detail

      • initialize

        void initialize()
                 throws HibernateException
        Initialize the proxy, fetching the target entity if necessary.
        HibernateException - Indicates a problem initializing the proxy.
      • getInternalIdentifier

        default getInternalIdentifier()
        Retrieve the identifier value for the entity our owning proxy represents.
        The identifier value.
      • getIdentifier getIdentifier()
        Retrieve the identifier value for the entity our owning proxy represents. When JPA proxy compliance is enabled the proxy is initialized.
        The identifier value.
      • setIdentifier

        void setIdentifier​( id)
        Set the identifier value for the entity our owning proxy represents.
        id - The identifier value.
      • getEntityName

        java.lang.String getEntityName()
        The entity-name of the entity our owning proxy represents.
        The entity-name.
      • getPersistentClass

        java.lang.Class getPersistentClass()
        Get the actual class of the entity. Generally, getEntityName() should be used instead.
        The actual entity class.
      • isUninitialized

        boolean isUninitialized()
        Is the proxy uninitialzed?
        True if uninitialized; false otherwise.
      • getImplementation

        java.lang.Object getImplementation()
        Return the underlying persistent object, initializing if necessary
        The underlying target entity.
      • getImplementation

        java.lang.Object getImplementation​(SharedSessionContractImplementor session)
                                    throws HibernateException
        Return the underlying persistent object in the given session, or null if not contained in this session's persistence context.
        session - The session to check
        The target, or null.
        HibernateException - Indicates problem locating the target.
      • setImplementation

        void setImplementation​(java.lang.Object target)
        Initialize the proxy manually by injecting its target.
        target - The proxy target (the actual entity being proxied).
      • isReadOnlySettingAvailable

        boolean isReadOnlySettingAvailable()
        Is the proxy's read-only/modifiable setting available?
        true, if the setting is available false, if the proxy is detached or its associated session is closed
      • setReadOnly

        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.
        readOnly - if true, the associated proxy is made read-only; if false, the associated proxy is made modifiable.
        TransientObjectException - if the proxy is not association with a session
        SessionException - if the proxy is associated with a session that is closed
        See Also:
        Session.setReadOnly(Object entityOrProxy, boolean readOnly)
      • getSession

        SharedSessionContractImplementor getSession()
        Get the session to which this proxy is associated, or null if it is not attached.
        The associated session.
      • setSession

        void setSession​(SharedSessionContractImplementor session)
                 throws HibernateException
        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.

        session - The session
        HibernateException - Indicates that the proxy was still contained in the persistence context of the "previous session".
      • setUnwrap

        void setUnwrap​(boolean unwrap)
      • isUnwrap

        boolean isUnwrap()