org.hibernate.jmx
Class SessionFactoryStub

java.lang.Object
  extended byorg.hibernate.jmx.SessionFactoryStub
All Implemented Interfaces:
Referenceable, Serializable, 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, where "current" is maintained in relation to the current JTA transaction; if a Session is not already associated with the current JTA transaction, a new Session will be opened and it will be associated with that JTA transaction.
 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.
 
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, where "current" is maintained in relation to the current JTA transaction; if a Session is not already associated with the current JTA transaction, a new Session will be opened and it will be associated with that JTA transaction.

This is only useful in managed environments where Hibernate has access to the TransactionManager for the given environment. A Transaction must also already be in effect prior to calls to this method. If either condition fails, an exception is thrown.

The Sessions returned from this method are automatically configured with both the auto-flush and auto-close attributes set to true, meaning that the Session will be automatically flushed and closed as part of the lifecycle for the JTA transaction to which it is associated.

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