Package org.hibernate

Class Hibernate


  • public final class Hibernate
    extends java.lang.Object
    • Provides access to the full range of Hibernate built-in types. Type instances may be used to bind values to query parameters.
    • A factory for new Blobs and Clobs.
    • Defines static methods for manipulation of proxies.
    See Also:
    Clob, Blob, Type
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void close​(java.util.Iterator iterator)
      Close an Iterator instances obtained from Query.iterate() immediately instead of waiting until the session is closed or disconnected.
      static java.lang.Class getClass​(java.lang.Object proxy)
      Get the true, underlying class of a proxied persistent class.
      static LobCreator getLobCreator​(SessionImplementor session)
      Obtain a lob creator for the given session.
      static LobCreator getLobCreator​(SharedSessionContractImplementor session)
      Obtain a lob creator for the given session.
      static LobCreator getLobCreator​(Session session)
      Obtain a lob creator for the given session.
      static void initialize​(java.lang.Object proxy)
      Force initialization of a proxy or persistent collection.
      static boolean isInitialized​(java.lang.Object proxy)
      Check if the proxy or persistent collection is initialized.
      static boolean isPropertyInitialized​(java.lang.Object proxy, java.lang.String propertyName)
      Check if the property is initialized.
      static java.lang.Object unproxy​(java.lang.Object proxy)
      Unproxies a HibernateProxy.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • initialize

        public static void initialize​(java.lang.Object proxy)
                               throws HibernateException
        Force initialization of a proxy or persistent collection.

        Note: This only ensures intialization of a proxy object or collection; it is not guaranteed that the elements INSIDE the collection will be initialized/materialized.

        Parameters:
        proxy - a persistable object, proxy, persistent collection or null
        Throws:
        HibernateException - if we can't initialize the proxy at this time, eg. the Session was closed
      • isInitialized

        public static boolean isInitialized​(java.lang.Object proxy)
        Check if the proxy or persistent collection is initialized.
        Parameters:
        proxy - a persistable object, proxy, persistent collection or null
        Returns:
        true if the argument is already initialized, or is not a proxy or collection
      • getClass

        public static java.lang.Class getClass​(java.lang.Object proxy)
        Get the true, underlying class of a proxied persistent class. This operation will initialize a proxy by side-effect.
        Parameters:
        proxy - a persistable object or proxy
        Returns:
        the true class of the instance
        Throws:
        HibernateException
      • getLobCreator

        public static LobCreator getLobCreator​(Session session)
        Obtain a lob creator for the given session.
        Parameters:
        session - The session for which to obtain a lob creator
        Returns:
        The log creator reference
      • getLobCreator

        public static LobCreator getLobCreator​(SharedSessionContractImplementor session)
        Obtain a lob creator for the given session.
        Parameters:
        session - The session for which to obtain a lob creator
        Returns:
        The log creator reference
      • getLobCreator

        public static LobCreator getLobCreator​(SessionImplementor session)
        Obtain a lob creator for the given session.
        Parameters:
        session - The session for which to obtain a lob creator
        Returns:
        The log creator reference
      • close

        public static void close​(java.util.Iterator iterator)
                          throws HibernateException
        Close an Iterator instances obtained from Query.iterate() immediately instead of waiting until the session is closed or disconnected.
        Parameters:
        iterator - an Iterator created by iterate()
        Throws:
        HibernateException - Indicates a problem closing the Hibernate iterator.
        java.lang.IllegalArgumentException - If the Iterator is not a "Hibernate Iterator".
        See Also:
        Query.iterate()
      • isPropertyInitialized

        public static boolean isPropertyInitialized​(java.lang.Object proxy,
                                                    java.lang.String propertyName)
        Check if the property is initialized. If the named property does not exist or is not persistent, this method always returns true.
        Parameters:
        proxy - The potential proxy
        propertyName - the name of a persistent attribute of the object
        Returns:
        true if the named property of the object is not listed as uninitialized; false otherwise
      • unproxy

        public static java.lang.Object unproxy​(java.lang.Object proxy)
        Unproxies a HibernateProxy. If the proxy is uninitialized, it automatically triggers an initialization. In case the supplied object is null or not a proxy, the object will be returned as-is.
        Parameters:
        proxy - the HibernateProxy to be unproxied
        Returns:
        the proxy's underlying implementation object, or the supplied object otherwise