Package org.hibernate

Interface SessionFactory

    • Method Detail

      • getSessionFactoryOptions

        SessionFactoryOptions getSessionFactoryOptions()
        Get the special options used to build the factory.
        Returns:
        The special options used to build the factory.
      • getCurrentSession

        Session getCurrentSession()
                           throws HibernateException
        Obtains the current session. The definition of what exactly "current" means controlled by the CurrentSessionContext impl configured for use.

        Note that for backwards compatibility, if a CurrentSessionContext is not configured but JTA is configured this will default to the JTASessionContext impl.

        Returns:
        The current session.
        Throws:
        HibernateException - Indicates an issue locating a suitable current session.
      • openStatelessSession

        StatelessSession openStatelessSession()
        Open a new stateless session.
        Returns:
        The created stateless session.
      • openStatelessSession

        StatelessSession openStatelessSession​(java.sql.Connection connection)
        Open a new stateless session, utilizing the specified JDBC Connection.
        Parameters:
        connection - Connection provided by the application.
        Returns:
        The created stateless session.
      • getStatistics

        Statistics getStatistics()
        Retrieve the statistics fopr this factory.
        Returns:
        The statistics.
      • close

        void close()
            throws HibernateException
        Destroy this SessionFactory and release all resources (caches, connection pools, etc).

        It is the responsibility of the application to ensure that there are no open sessions before calling this method as the impact on those sessions is indeterminate.

        No-ops if already closed.

        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface EntityManagerFactory
        Throws:
        HibernateException - Indicates an issue closing the factory.
      • isClosed

        boolean isClosed()
        Is this factory already closed?
        Returns:
        True if this factory is already closed; false otherwise.
      • getCache

        Cache getCache()
        Obtain direct access to the underlying cache regions.
        Specified by:
        getCache in interface EntityManagerFactory
        Returns:
        The direct cache access API.
      • getDefinedFilterNames

        java.util.Set getDefinedFilterNames()
        Obtain a set of the names of all filters defined on this SessionFactory.
        Returns:
        The set of filter names.
      • getFilterDefinition

        FilterDefinition getFilterDefinition​(java.lang.String filterName)
                                      throws HibernateException
        Obtain the definition of a filter by name.
        Parameters:
        filterName - The name of the filter for which to obtain the definition.
        Returns:
        The filter definition.
        Throws:
        HibernateException - If no filter defined with the given name.
      • containsFetchProfileDefinition

        boolean containsFetchProfileDefinition​(java.lang.String name)
        Determine if this session factory contains a fetch profile definition registered under the given name.
        Parameters:
        name - The name to check
        Returns:
        True if there is such a fetch profile; false otherwise.
      • getClassMetadata

        @Deprecated
        ClassMetadata getClassMetadata​(java.lang.Class entityClass)
        Deprecated.
        Use the descriptors from EntityManagerFactory.getMetamodel() instead
        Retrieve the ClassMetadata associated with the given entity class.
        Parameters:
        entityClass - The entity class
        Returns:
        The metadata associated with the given entity; may be null if no such entity was mapped.
        Throws:
        HibernateException - Generally null is returned instead of throwing.
      • getClassMetadata

        @Deprecated
        ClassMetadata getClassMetadata​(java.lang.String entityName)
        Deprecated.
        Use the descriptors from EntityManagerFactory.getMetamodel() instead
        Retrieve the ClassMetadata associated with the given entity class.
        Parameters:
        entityName - The entity class
        Returns:
        The metadata associated with the given entity; may be null if no such entity was mapped.
        Throws:
        HibernateException - Generally null is returned instead of throwing.
        Since:
        3.0
      • getCollectionMetadata

        @Deprecated
        CollectionMetadata getCollectionMetadata​(java.lang.String roleName)
        Deprecated.
        Use the descriptors from EntityManagerFactory.getMetamodel() instead
        Get the CollectionMetadata associated with the named collection role.
        Parameters:
        roleName - The collection role (in form [owning-entity-name].[collection-property-name]).
        Returns:
        The metadata associated with the given collection; may be null if no such collection was mapped.
        Throws:
        HibernateException - Generally null is returned instead of throwing.