Top Description Fields Constructors Methods
org.hibernate.jmx

public Class SessionFactoryStub

extends Object
implements SessionFactory
Class Inheritance
All Implemented Interfaces
org.hibernate.SessionFactory, java.io.Serializable, javax.naming.Referenceable
Imports
java.io.InvalidObjectException, .ObjectStreamException, .Serializable, java.sql.Connection, java.util.Map, .Set, javax.naming.NamingException, .Reference, .StringRefAddr, org.slf4j.Logger, .LoggerFactory, org.hibernate.AssertionFailure, .HibernateException, .Interceptor, .SessionFactory, .StatelessSession, .Cache, .TypeHelper, org.hibernate.engine.FilterDefinition, org.hibernate.id.IdentifierGenerator, .UUIDGenerator, org.hibernate.impl.SessionFactoryObjectFactory, org.hibernate.metadata.ClassMetadata, .CollectionMetadata, org.hibernate.stat.Statistics

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

Field Summary

Modifier and TypeField and Description
private transient SessionFactory
private static final Logger
private String
private transient HibernateService
private String
private static final IdentifierGenerator

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements org.hibernate.SessionFactory.close.

Destroy this SessionFactory and release all resources (caches, connection pools, etc).
public boolean
containsFetchProfileDefinition(String
The name to check
name
)

Implements org.hibernate.SessionFactory.containsFetchProfileDefinition.

Determine if this session factory contains a fetch profile definition registered under the given name.
public void
evict(Class<T>
The entity class for which to evict data.
persistentClass
,
Serializable
The entity id
id
)

Implements org.hibernate.SessionFactory.evict.

Evict an entry from the second-level cache.
public void
evict(Class<T>
The entity class for which to evict data.
persistentClass
)

Implements org.hibernate.SessionFactory.evict.

Evict all entries from the second-level cache.
public void
evictCollection(String
The name of the collection role
roleName
,
Serializable
The id of the collection owner
id
)

Implements org.hibernate.SessionFactory.evictCollection.

Evict an entry from the second-level cache.
public void
evictCollection(String
The name of the collection role whose regions should be evicted
roleName
)

Implements org.hibernate.SessionFactory.evictCollection.

Evict all entries from the second-level cache.
public void
evictEntity(String
The entity name for which to evict data.
entityName
,
Serializable
The entity id
id
)

Implements org.hibernate.SessionFactory.evictEntity.

Evict an entry from the second-level cache.
public void
evictEntity(String
The entity name for which to evict data.
entityName
)

Implements org.hibernate.SessionFactory.evictEntity.

Evict all entries from the second-level cache.
public void
evictQueries()

Implements org.hibernate.SessionFactory.evictQueries.

Evict any query result sets cached in the default query cache region.
public void
evictQueries(String
The named query cache region from which to evict.
cacheRegion
)

Implements org.hibernate.SessionFactory.evictQueries.

Evict any query result sets cached in the named query cache region.
public Map<String, ClassMetadata>
getAllClassMetadata()

Implements org.hibernate.SessionFactory.getAllClassMetadata.

Retrieve the ClassMetadata for all mapped entities.
public Map<K, V>
public Cache
getCache()

Implements org.hibernate.SessionFactory.getCache.

Obtain direct access to the underlying cache regions.
public ClassMetadata
getClassMetadata(Class<T>
The entity class
persistentClass
)

Implements org.hibernate.SessionFactory.getClassMetadata.

Retrieve the ClassMetadata associated with the given entity class.
public ClassMetadata
getClassMetadata(String
The entity class
entityName
)

Implements org.hibernate.SessionFactory.getClassMetadata.

Retrieve the ClassMetadata associated with the given entity class.
public CollectionMetadata
getCollectionMetadata(String
The collection role (in form [owning-entity-name].[collection-property-name]).
roleName
)

Implements org.hibernate.SessionFactory.getCollectionMetadata.

Get the CollectionMetadata associated with the named collection role.
public Session
getCurrentSession()

Implements org.hibernate.SessionFactory.getCurrentSession.

Obtains the current session.
public Set<E>
getDefinedFilterNames()

Implements org.hibernate.SessionFactory.getDefinedFilterNames.

Obtain a set of the names of all filters defined on this SessionFactory.
public FilterDefinition
getFilterDefinition(String
The name of the filter for which to obtain the definition.
filterName
)

Implements org.hibernate.SessionFactory.getFilterDefinition.

Obtain the definition of a filter by name.
private synchronized SessionFactory
public Reference
getReference()

Implements javax.naming.Referenceable.getReference.

Retrieves the Reference of this object.
public Statistics
getStatistics()

Implements org.hibernate.SessionFactory.getStatistics.

Retrieve the statistics fopr this factory.
public TypeHelper
public boolean
isClosed()

Implements org.hibernate.SessionFactory.isClosed.

Is this factory already closed?
public Session
openSession(Connection
a connection provided by the application.
connection
,
Interceptor
a session-scoped interceptor
interceptor
)

Implements org.hibernate.SessionFactory.openSession.

Open a Session, utilizing the specfied JDBC Connection and specified Interceptor.
public Session
openSession(Interceptor
a session-scoped interceptor
interceptor
)

Implements org.hibernate.SessionFactory.openSession.

Open a Session, utilizing the specified Interceptor.
public Session
public Session
openSession(Connection
a connection provided by the application.
conn
)

Implements org.hibernate.SessionFactory.openSession.

Open a Session, utilizing the specfied JDBC Connection.
public StatelessSession
public StatelessSession
openStatelessSession(Connection
Connection provided by the application.
conn
)

Implements org.hibernate.SessionFactory.openStatelessSession.

Open a new stateless session, utilizing the specified JDBC Connection.
private Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

implback to summary
private transient SessionFactory impl
logback to summary
private static final Logger log
nameback to summary
private String name
serviceback to summary
private transient HibernateService service
uuidback to summary
private String uuid
UUID_GENERATORback to summary
private static final IdentifierGenerator UUID_GENERATOR

Constructor Detail

SessionFactoryStubback to summary
pack-priv SessionFactoryStub(HibernateService service)

Method Detail

closeback to summary
public void close() throws HibernateException

Implements org.hibernate.SessionFactory.close.

Doc from org.hibernate.SessionFactory.close.

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.

Exceptions
HibernateException:
Indicates an issue closing the factory.
containsFetchProfileDefinitionback to summary
public boolean containsFetchProfileDefinition(String name)

Implements org.hibernate.SessionFactory.containsFetchProfileDefinition.

Doc from org.hibernate.SessionFactory.containsFetchProfileDefinition.

Determine if this session factory contains a fetch profile definition registered under the given name.

Parameters
name:String

The name to check

Returns:boolean

True if there is such a fetch profile; false otherwise.

evictback to summary
public void evict(Class<T> persistentClass, Serializable id) throws HibernateException

Implements org.hibernate.SessionFactory.evict.

Doc from org.hibernate.SessionFactory.evict.

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.

Parameters
persistentClass:Class<T>

The entity class for which to evict data.

id:Serializable

The entity id

Exceptions
HibernateException:
Generally will mean that either that 'persisttentClass' did not name a mapped entity or a problem communicating with underlying cache impl.
evictback to summary
public void evict(Class<T> persistentClass) throws HibernateException

Implements org.hibernate.SessionFactory.evict.

Doc from org.hibernate.SessionFactory.evict.

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.

Parameters
persistentClass:Class<T>

The entity class for which to evict data.

Exceptions
HibernateException:
Generally will mean that either that 'persisttentClass' did not name a mapped entity or a problem communicating with underlying cache impl.
evictCollectionback to summary
public void evictCollection(String roleName, Serializable id) throws HibernateException

Implements org.hibernate.SessionFactory.evictCollection.

Doc from org.hibernate.SessionFactory.evictCollection.

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.

Parameters
roleName:String

The name of the collection role

id:Serializable

The id of the collection owner

Exceptions
HibernateException:
Generally will mean that either that 'roleName' did not name a mapped collection or a problem communicating with underlying cache impl.
evictCollectionback to summary
public void evictCollection(String roleName) throws HibernateException

Implements org.hibernate.SessionFactory.evictCollection.

Doc from org.hibernate.SessionFactory.evictCollection.

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.

Parameters
roleName:String

The name of the collection role whose regions should be evicted

Exceptions
HibernateException:
Generally will mean that either that 'roleName' did not name a mapped collection or a problem communicating with underlying cache impl.
evictEntityback to summary
public void evictEntity(String entityName, Serializable id) throws HibernateException

Implements org.hibernate.SessionFactory.evictEntity.

Doc from org.hibernate.SessionFactory.evictEntity.

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.

Parameters
entityName:String

The entity name for which to evict data.

id:Serializable

The entity id

Exceptions
HibernateException:
Generally will mean that either that 'persisttentClass' did not name a mapped entity or a problem communicating with underlying cache impl.
evictEntityback to summary
public void evictEntity(String entityName) throws HibernateException

Implements org.hibernate.SessionFactory.evictEntity.

Doc from org.hibernate.SessionFactory.evictEntity.

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.

Parameters
entityName:String

The entity name for which to evict data.

Exceptions
HibernateException:
Generally will mean that either that 'persisttentClass' did not name a mapped entity or a problem communicating with underlying cache impl.
evictQueriesback to summary
public void evictQueries() throws HibernateException

Implements org.hibernate.SessionFactory.evictQueries.

Doc from org.hibernate.SessionFactory.evictQueries.

Evict any query result sets cached in the default query cache region.

Exceptions
HibernateException:
Indicate a problem communicating with underlying cache impl.
evictQueriesback to summary
public void evictQueries(String cacheRegion) throws HibernateException

Implements org.hibernate.SessionFactory.evictQueries.

Doc from org.hibernate.SessionFactory.evictQueries.

Evict any query result sets cached in the named query cache region.

Parameters
cacheRegion:String

The named query cache region from which to evict.

Exceptions
HibernateException:
Since a not-found 'cacheRegion' simply no-ops, this should indicate a problem communicating with underlying cache impl.
getAllClassMetadataback to summary
public Map<String, ClassMetadata> getAllClassMetadata() throws HibernateException

Implements org.hibernate.SessionFactory.getAllClassMetadata.

Doc from org.hibernate.SessionFactory.getAllClassMetadata.

Retrieve the ClassMetadata for all mapped entities.

Returns:Map<String, ClassMetadata>

A map containing all ClassMetadata keyed by the corresponding String entity-name.

Exceptions
HibernateException:
Generally empty map is returned instead of throwing.
getAllCollectionMetadataback to summary
public Map<K, V> getAllCollectionMetadata() throws HibernateException

Implements org.hibernate.SessionFactory.getAllCollectionMetadata.

Doc from org.hibernate.SessionFactory.getAllCollectionMetadata.

Get the CollectionMetadata for all mapped collections

Returns:Map<K, V>

a map from String to CollectionMetadata

Exceptions
HibernateException:
Generally empty map is returned instead of throwing.
getCacheback to summary
public Cache getCache()

Implements org.hibernate.SessionFactory.getCache.

Doc from org.hibernate.SessionFactory.getCache.

Obtain direct access to the underlying cache regions.

Returns:Cache

The direct cache access API.

getClassMetadataback to summary
public ClassMetadata getClassMetadata(Class<T> persistentClass) throws HibernateException

Implements org.hibernate.SessionFactory.getClassMetadata.

Doc from org.hibernate.SessionFactory.getClassMetadata.

Retrieve the ClassMetadata associated with the given entity class.

Parameters
persistentClass:Class<T>

The entity class

Returns:ClassMetadata

The metadata associated with the given entity; may be null if no such entity was mapped.

Exceptions
HibernateException:
Generally null is returned instead of throwing.
getClassMetadataback to summary
public ClassMetadata getClassMetadata(String entityName) throws HibernateException

Implements org.hibernate.SessionFactory.getClassMetadata.

Doc from org.hibernate.SessionFactory.getClassMetadata.

Retrieve the ClassMetadata associated with the given entity class.

Parameters
entityName:String

The entity class

Returns:ClassMetadata

The metadata associated with the given entity; may be null if no such entity was mapped.

Exceptions
HibernateException:
Generally null is returned instead of throwing.
getCollectionMetadataback to summary
public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException

Implements org.hibernate.SessionFactory.getCollectionMetadata.

Doc from org.hibernate.SessionFactory.getCollectionMetadata.

Get the CollectionMetadata associated with the named collection role.

Parameters
roleName:String

The collection role (in form [owning-entity-name].[collection-property-name]).

Returns:CollectionMetadata

The metadata associated with the given collection; may be null if no such collection was mapped.

Exceptions
HibernateException:
Generally null is returned instead of throwing.
getCurrentSessionback to summary
public Session getCurrentSession()

Implements org.hibernate.SessionFactory.getCurrentSession.

Doc from org.hibernate.SessionFactory.getCurrentSession.

Obtains the current session. The definition of what exactly "current" means controlled by the org.hibernate.context.CurrentSessionContext impl configured for use.

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

Returns:Session

The current session.

getDefinedFilterNamesback to summary
public Set<E> getDefinedFilterNames()

Implements org.hibernate.SessionFactory.getDefinedFilterNames.

Doc from org.hibernate.SessionFactory.getDefinedFilterNames.

Obtain a set of the names of all filters defined on this SessionFactory.

Returns:Set<E>

The set of filter names.

getFilterDefinitionback to summary
public FilterDefinition getFilterDefinition(String filterName) throws HibernateException

Implements org.hibernate.SessionFactory.getFilterDefinition.

Doc from org.hibernate.SessionFactory.getFilterDefinition.

Obtain the definition of a filter by name.

Parameters
filterName:String

The name of the filter for which to obtain the definition.

Returns:FilterDefinition

The filter definition.

Exceptions
HibernateException:
If no filter defined with the given name.
getImplback to summary
private synchronized SessionFactory getImpl()
getReferenceback to summary
public Reference getReference() throws NamingException

Implements javax.naming.Referenceable.getReference.

Doc from javax.naming.Referenceable.getReference.

Retrieves the Reference of this object.

Returns:Reference

The non-null Reference of this object.

Exceptions
NamingException:
If a naming exception was encountered while retrieving the reference.
See Also
javax.naming.Referenceable#getReference()
getStatisticsback to summary
public Statistics getStatistics()

Implements org.hibernate.SessionFactory.getStatistics.

Doc from org.hibernate.SessionFactory.getStatistics.

Retrieve the statistics fopr this factory.

Returns:Statistics

The statistics.

getTypeHelperback to summary
public TypeHelper getTypeHelper()

Implements org.hibernate.SessionFactory.getTypeHelper.

Doc from org.hibernate.SessionFactory.getTypeHelper.

Retrieve this factory's TypeHelper

Returns:TypeHelper

The factory's TypeHelper

isClosedback to summary
public boolean isClosed()

Implements org.hibernate.SessionFactory.isClosed.

Doc from org.hibernate.SessionFactory.isClosed.

Is this factory already closed?

Returns:boolean

True if this factory is already closed; false otherwise.

openSessionback to summary
public Session openSession(Connection connection, Interceptor interceptor)

Implements org.hibernate.SessionFactory.openSession.

Doc from org.hibernate.SessionFactory.openSession.

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 org.hibernate.connection.ConnectionProvider instead as a highly recommended alternative.

Parameters
connection:Connection

a connection provided by the application.

interceptor:Interceptor

a session-scoped interceptor

Returns:Session

The created session.

openSessionback to summary
public Session openSession(Interceptor interceptor) throws HibernateException

Implements org.hibernate.SessionFactory.openSession.

Doc from org.hibernate.SessionFactory.openSession.

Open a Session, utilizing the specified Interceptor.

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

Parameters
interceptor:Interceptor

a session-scoped interceptor

Returns:Session

The created session.

Exceptions
HibernateException:
Indicates a peroblem opening the session; pretty rare here.
openSessionback to summary
public Session openSession() throws HibernateException

Implements org.hibernate.SessionFactory.openSession.

Doc from org.hibernate.SessionFactory.openSession.

Open a Session.

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

Returns:Session

The created session.

Exceptions
HibernateException:
Indicates a peroblem opening the session; pretty rare here.
openSessionback to summary
public Session openSession(Connection conn)

Implements org.hibernate.SessionFactory.openSession.

Doc from org.hibernate.SessionFactory.openSession.

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 org.hibernate.connection.ConnectionProvider instead as a highly recommended alternative.

Parameters
conn:Connection

a connection provided by the application.

Returns:Session

The created session.

openStatelessSessionback to summary
public StatelessSession openStatelessSession()

Implements org.hibernate.SessionFactory.openStatelessSession.

Doc from org.hibernate.SessionFactory.openStatelessSession.

Open a new stateless session.

Returns:StatelessSession

The created stateless session.

openStatelessSessionback to summary
public StatelessSession openStatelessSession(Connection conn)

Implements org.hibernate.SessionFactory.openStatelessSession.

Doc from org.hibernate.SessionFactory.openStatelessSession.

Open a new stateless session, utilizing the specified JDBC Connection.

Parameters
conn:Connection

Connection provided by the application.

Returns:StatelessSession

The created stateless session.

readResolveback to summary
private Object readResolve() throws ObjectStreamException