Class SessionFactoryStub

java.lang.Object
org.hibernate.jmx.SessionFactoryStub
All Implemented Interfaces:
Serializable, Referenceable, SessionFactory

public class SessionFactoryStub extends Object implements SessionFactory
A flyweight for SessionFactory. If the MBean itself does not have classpath to the persistent classes, then a stub will be registered with JNDI and the actual SessionFactoryImpl built upon first access.
See Also:
  • Method Details

    • openSession

      public Session openSession(Connection connection, Interceptor interceptor)
      Description copied from interface: SessionFactory
      Open a Session, utilizing the specfied JDBC Connection and specified Interceptor.

      Note that the second-level cache will be disabled if you supply a JDBC connection. Hibernate will not be able to track any statements you might have executed in the same transaction. Consider implementing your own ConnectionProvider instead as a highly recommended alternative.

      Specified by:
      openSession in interface SessionFactory
      Parameters:
      connection - a connection provided by the application.
      interceptor - a session-scoped interceptor
      Returns:
      The created session.
    • openSession

      public Session openSession(Interceptor interceptor) throws HibernateException
      Description copied from interface: SessionFactory
      Open a Session, utilizing the specified Interceptor.

      JDBC connection(s will be obtained from the configured ConnectionProvider as needed to perform requested work.

      Specified by:
      openSession in interface SessionFactory
      Parameters:
      interceptor - a session-scoped interceptor
      Returns:
      The created session.
      Throws:
      HibernateException - Indicates a peroblem opening the session; pretty rare here.
    • openSession

      public Session openSession() throws HibernateException
      Description copied from interface: SessionFactory
      Open a Session.

      JDBC connection(s will be obtained from the configured ConnectionProvider as needed to perform requested work.

      Specified by:
      openSession in interface SessionFactory
      Returns:
      The created session.
      Throws:
      HibernateException - Indicates a peroblem opening the session; pretty rare here.
    • openSession

      public Session openSession(Connection conn)
      Description copied from interface: SessionFactory
      Open a Session, utilizing the specfied JDBC Connection.

      Note that the second-level cache will be disabled if you supply a JDBC connection. Hibernate will not be able to track any statements you might have executed in the same transaction. Consider implementing your own ConnectionProvider instead as a highly recommended alternative.

      Specified by:
      openSession in interface SessionFactory
      Parameters:
      conn - a connection provided by the application.
      Returns:
      The created session.
    • getCurrentSession

      public Session getCurrentSession()
      Description copied from interface: SessionFactory
      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 a JTA TransactionManagerLookup is configured this will default to the JTASessionContext impl.

      Specified by:
      getCurrentSession in interface SessionFactory
      Returns:
      The current session.
    • getReference

      public Reference getReference() throws NamingException
      Specified by:
      getReference in interface Referenceable
      Throws:
      NamingException
      See Also:
    • getClassMetadata

      public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException
      Description copied from interface: SessionFactory
      Retrieve the ClassMetadata associated with the given entity class.
      Specified by:
      getClassMetadata in interface SessionFactory
      Parameters:
      persistentClass - 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

      public ClassMetadata getClassMetadata(String entityName) throws HibernateException
      Description copied from interface: SessionFactory
      Retrieve the ClassMetadata associated with the given entity class.
      Specified by:
      getClassMetadata in interface SessionFactory
      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.
    • getCollectionMetadata

      public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException
      Description copied from interface: SessionFactory
      Get the CollectionMetadata associated with the named collection role.
      Specified by:
      getCollectionMetadata in interface SessionFactory
      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.
    • getAllClassMetadata

      public Map<String,ClassMetadata> getAllClassMetadata() throws HibernateException
      Description copied from interface: SessionFactory
      Retrieve the ClassMetadata for all mapped entities.
      Specified by:
      getAllClassMetadata in interface SessionFactory
      Returns:
      A map containing all ClassMetadata keyed by the corresponding String entity-name.
      Throws:
      HibernateException - Generally empty map is returned instead of throwing.
    • getAllCollectionMetadata

      public Map getAllCollectionMetadata() throws HibernateException
      Description copied from interface: SessionFactory
      Get the CollectionMetadata for all mapped collections
      Specified by:
      getAllCollectionMetadata in interface SessionFactory
      Returns:
      a map from String to CollectionMetadata
      Throws:
      HibernateException - Generally empty map is returned instead of throwing.
    • close

      public void close() throws HibernateException
      Description copied from interface: SessionFactory
      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 SessionFactory
      Throws:
      HibernateException - Indicates an issue closing the factory.
    • isClosed

      public boolean isClosed()
      Description copied from interface: SessionFactory
      Is this factory already closed?
      Specified by:
      isClosed in interface SessionFactory
      Returns:
      True if this factory is already closed; false otherwise.
    • getCache

      public Cache getCache()
      Description copied from interface: SessionFactory
      Obtain direct access to the underlying cache regions.
      Specified by:
      getCache in interface SessionFactory
      Returns:
      The direct cache access API.
    • evict

      public void evict(Class persistentClass, Serializable id) throws HibernateException
      Description copied from interface: SessionFactory
      Evict an entry from the second-level cache. This method occurs outside of any transaction; it performs an immediate "hard" remove, so does not respect any transaction isolation semantics of the usage strategy. Use with care.
      Specified by:
      evict in interface SessionFactory
      Parameters:
      persistentClass - The entity class for which to evict data.
      id - The entity id
      Throws:
      HibernateException - Generally will mean that either that 'persisttentClass' did not name a mapped entity or a problem communicating with underlying cache impl.
    • evict

      public void evict(Class persistentClass) throws HibernateException
      Description copied from interface: SessionFactory
      Evict all entries from the second-level cache. This method occurs outside of any transaction; it performs an immediate "hard" remove, so does not respect any transaction isolation semantics of the usage strategy. Use with care.
      Specified by:
      evict in interface SessionFactory
      Parameters:
      persistentClass - The entity class for which to evict data.
      Throws:
      HibernateException - Generally will mean that either that 'persisttentClass' did not name a mapped entity or a problem communicating with underlying cache impl.
    • evictEntity

      public void evictEntity(String entityName, Serializable id) throws HibernateException
      Description copied from interface: SessionFactory
      Evict an entry from the second-level cache. This method occurs outside of any transaction; it performs an immediate "hard" remove, so does not respect any transaction isolation semantics of the usage strategy. Use with care.
      Specified by:
      evictEntity in interface SessionFactory
      Parameters:
      entityName - The entity name for which to evict data.
      id - The entity id
      Throws:
      HibernateException - Generally will mean that either that 'persisttentClass' did not name a mapped entity or a problem communicating with underlying cache impl.
    • evictEntity

      public void evictEntity(String entityName) throws HibernateException
      Description copied from interface: SessionFactory
      Evict all entries from the second-level cache. This method occurs outside of any transaction; it performs an immediate "hard" remove, so does not respect any transaction isolation semantics of the usage strategy. Use with care.
      Specified by:
      evictEntity in interface SessionFactory
      Parameters:
      entityName - The entity name for which to evict data.
      Throws:
      HibernateException - Generally will mean that either that 'persisttentClass' did not name a mapped entity or a problem communicating with underlying cache impl.
    • evictCollection

      public void evictCollection(String roleName, Serializable id) throws HibernateException
      Description copied from interface: SessionFactory
      Evict an entry from the second-level cache. This method occurs outside of any transaction; it performs an immediate "hard" remove, so does not respect any transaction isolation semantics of the usage strategy. Use with care.
      Specified by:
      evictCollection in interface SessionFactory
      Parameters:
      roleName - The name of the collection role
      id - The id of the collection owner
      Throws:
      HibernateException - Generally will mean that either that 'roleName' did not name a mapped collection or a problem communicating with underlying cache impl.
    • evictCollection

      public void evictCollection(String roleName) throws HibernateException
      Description copied from interface: SessionFactory
      Evict all entries from the second-level cache. This method occurs outside of any transaction; it performs an immediate "hard" remove, so does not respect any transaction isolation semantics of the usage strategy. Use with care.
      Specified by:
      evictCollection in interface SessionFactory
      Parameters:
      roleName - The name of the collection role whose regions should be evicted
      Throws:
      HibernateException - Generally will mean that either that 'roleName' did not name a mapped collection or a problem communicating with underlying cache impl.
    • evictQueries

      public void evictQueries() throws HibernateException
      Description copied from interface: SessionFactory
      Evict any query result sets cached in the default query cache region.
      Specified by:
      evictQueries in interface SessionFactory
      Throws:
      HibernateException - Indicate a problem communicating with underlying cache impl.
    • evictQueries

      public void evictQueries(String cacheRegion) throws HibernateException
      Description copied from interface: SessionFactory
      Evict any query result sets cached in the named query cache region.
      Specified by:
      evictQueries in interface SessionFactory
      Parameters:
      cacheRegion - The named query cache region from which to evict.
      Throws:
      HibernateException - Since a not-found 'cacheRegion' simply no-ops, this should indicate a problem communicating with underlying cache impl.
    • getStatistics

      public Statistics getStatistics()
      Description copied from interface: SessionFactory
      Retrieve the statistics fopr this factory.
      Specified by:
      getStatistics in interface SessionFactory
      Returns:
      The statistics.
    • openStatelessSession

      public StatelessSession openStatelessSession()
      Description copied from interface: SessionFactory
      Open a new stateless session.
      Specified by:
      openStatelessSession in interface SessionFactory
      Returns:
      The created stateless session.
    • openStatelessSession

      public StatelessSession openStatelessSession(Connection conn)
      Description copied from interface: SessionFactory
      Open a new stateless session, utilizing the specified JDBC Connection.
      Specified by:
      openStatelessSession in interface SessionFactory
      Parameters:
      conn - Connection provided by the application.
      Returns:
      The created stateless session.
    • getDefinedFilterNames

      public Set getDefinedFilterNames()
      Description copied from interface: SessionFactory
      Obtain a set of the names of all filters defined on this SessionFactory.
      Specified by:
      getDefinedFilterNames in interface SessionFactory
      Returns:
      The set of filter names.
    • getFilterDefinition

      public FilterDefinition getFilterDefinition(String filterName) throws HibernateException
      Description copied from interface: SessionFactory
      Obtain the definition of a filter by name.
      Specified by:
      getFilterDefinition in interface SessionFactory
      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

      public boolean containsFetchProfileDefinition(String name)
      Description copied from interface: SessionFactory
      Determine if this session factory contains a fetch profile definition registered under the given name.
      Specified by:
      containsFetchProfileDefinition in interface SessionFactory
      Parameters:
      name - The name to check
      Returns:
      True if there is such a fetch profile; false otherwise.
    • getTypeHelper

      public TypeHelper getTypeHelper()
      Description copied from interface: SessionFactory
      Retrieve this factory's TypeHelper
      Specified by:
      getTypeHelper in interface SessionFactory
      Returns:
      The factory's TypeHelper