org.hibernate.jmx
Class SessionFactoryStub

java.lang.Object
  extended by 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.

Author:
Gavin King
See Also:
Serialized Form

Method Summary
 void close()
          Destroy this SessionFactory and release all resources (caches, connection pools, etc).
 void evict(Class persistentClass)
          Evict all entries from the second-level cache.
 void evict(Class persistentClass, Serializable id)
          Evict an entry from the second-level cache.
 void evictCollection(String roleName)
          Evict all entries from the second-level cache.
 void evictCollection(String roleName, Serializable id)
          Evict an entry from the second-level cache.
 void evictEntity(String entityName)
          Evict all entries from the second-level cache.
 void evictEntity(String entityName, Serializable id)
          Evict an entry from the second-level cache.
 void evictQueries()
          Evict any query result sets cached in the default query cache region.
 void evictQueries(String cacheRegion)
          Evict any query result sets cached in the named query cache region.
 Map getAllClassMetadata()
          Get all ClassMetadata as a Map from entityname String to metadata object
 Map getAllCollectionMetadata()
          Get all CollectionMetadata as a Map from role name to metadata object
 ClassMetadata getClassMetadata(Class persistentClass)
          Get the ClassMetadata associated with the given entity class
 ClassMetadata getClassMetadata(String entityName)
          Get the ClassMetadata associated with the given entity name
 CollectionMetadata getCollectionMetadata(String roleName)
          Get the CollectionMetadata associated with the named collection role
 Session getCurrentSession()
          Obtains the current session.
 Set getDefinedFilterNames()
          Obtain a set of the names of all filters defined on this SessionFactory.
 FilterDefinition getFilterDefinition(String filterName)
          Obtain the definition of a filter by name.
 Reference getReference()
           
 Statistics getStatistics()
          Get the statistics for this session factory
 boolean isClosed()
          Was this SessionFactory already closed?
 Session openSession()
          Create database connection and open a Session on it.
 Session openSession(Connection conn)
          Open a Session on the given connection.
 Session openSession(Connection connection, Interceptor interceptor)
          Open a Session on the given connection, specifying an interceptor.
 Session openSession(Interceptor interceptor)
          Create database connection and open a Session on it, specifying an interceptor.
 StatelessSession openStatelessSession()
          Get a new stateless session.
 StatelessSession openStatelessSession(Connection conn)
          Get a new stateless session for the given JDBC connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

openSession

public Session openSession(Connection connection,
                           Interceptor interceptor)
Description copied from interface: SessionFactory
Open a Session on the given connection, specifying an 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.

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

openSession

public Session openSession(Interceptor interceptor)
                    throws HibernateException
Description copied from interface: SessionFactory
Create database connection and open a Session on it, specifying an interceptor.

Specified by:
openSession in interface SessionFactory
Parameters:
interceptor - a session-scoped interceptor
Returns:
Session
Throws:
HibernateException

openSession

public Session openSession()
                    throws HibernateException
Description copied from interface: SessionFactory
Create database connection and open a Session on it.

Specified by:
openSession in interface SessionFactory
Returns:
Session
Throws:
HibernateException

openSession

public Session openSession(Connection conn)
Description copied from interface: SessionFactory
Open a Session on the given 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.

Specified by:
openSession in interface SessionFactory
Parameters:
conn - a connection provided by the application.
Returns:
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:
Referenceable.getReference()

getClassMetadata

public ClassMetadata getClassMetadata(Class persistentClass)
                               throws HibernateException
Description copied from interface: SessionFactory
Get the ClassMetadata associated with the given entity class

Specified by:
getClassMetadata in interface SessionFactory
Throws:
HibernateException
See Also:
ClassMetadata

getClassMetadata

public ClassMetadata getClassMetadata(String entityName)
                               throws HibernateException
Description copied from interface: SessionFactory
Get the ClassMetadata associated with the given entity name

Specified by:
getClassMetadata in interface SessionFactory
Throws:
HibernateException
See Also:
ClassMetadata

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
Throws:
HibernateException
See Also:
CollectionMetadata

getAllClassMetadata

public Map getAllClassMetadata()
                        throws HibernateException
Description copied from interface: SessionFactory
Get all ClassMetadata as a Map from entityname String to metadata object

Specified by:
getAllClassMetadata in interface SessionFactory
Returns:
a map from String an entity name to ClassMetaData
Throws:
HibernateException
See Also:
ClassMetadata

getAllCollectionMetadata

public Map getAllCollectionMetadata()
                             throws HibernateException
Description copied from interface: SessionFactory
Get all CollectionMetadata as a Map from role name to metadata object

Specified by:
getAllCollectionMetadata in interface SessionFactory
Returns:
a map from String to CollectionMetadata
Throws:
HibernateException
See Also:
CollectionMetadata

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 close().

Specified by:
close in interface SessionFactory
Throws:
HibernateException

isClosed

public boolean isClosed()
Description copied from interface: SessionFactory
Was this SessionFactory already closed?

Specified by:
isClosed in interface SessionFactory

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
Throws:
HibernateException

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
Throws:
HibernateException

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
Throws:
HibernateException

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
Throws:
HibernateException

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
Throws:
HibernateException

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
Throws:
HibernateException

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

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
Throws:
HibernateException

getStatistics

public Statistics getStatistics()
Description copied from interface: SessionFactory
Get the statistics for this session factory

Specified by:
getStatistics in interface SessionFactory

openStatelessSession

public StatelessSession openStatelessSession()
Description copied from interface: SessionFactory
Get a new stateless session.

Specified by:
openStatelessSession in interface SessionFactory

openStatelessSession

public StatelessSession openStatelessSession(Connection conn)
Description copied from interface: SessionFactory
Get a new stateless session for the given JDBC connection.

Specified by:
openStatelessSession in interface SessionFactory

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.