public final class SessionFactoryImpl extends Object implements SessionFactory, SessionFactoryImplementor
ConnectionProvider,
Session,
QueryTranslator,
EntityPersister,
CollectionPersister,
Serialized Form| Constructor and Description |
|---|
SessionFactoryImpl(Configuration cfg,
Mapping mapping,
Settings settings,
EventListeners listeners,
SessionFactoryObserver observer) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the session factory, releasing all held resources.
|
boolean |
containsFetchProfileDefinition(String name)
Determine if this session factory contains a fetch profile definition
registered under the given name.
|
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 regionName)
Evict any query result sets cached in the named query cache region.
|
Map<String,ClassMetadata> |
getAllClassMetadata()
Retrieve the
ClassMetadata for all mapped entities. |
Map |
getAllCollectionMetadata()
Get the
CollectionMetadata for all mapped collections |
Map |
getAllSecondLevelCacheRegions()
Get a map of all the second level cache regions currently maintained in
this session factory.
|
BatcherFactory |
getBatcherFactory() |
Cache |
getCache()
Obtain direct access to the underlying cache regions.
|
ClassMetadata |
getClassMetadata(Class persistentClass)
Retrieve the
ClassMetadata associated with the given entity class. |
ClassMetadata |
getClassMetadata(String entityName)
Retrieve the
ClassMetadata associated with the given entity class. |
CollectionMetadata |
getCollectionMetadata(String roleName)
Get the
CollectionMetadata associated with the named collection role. |
CollectionPersister |
getCollectionPersister(String role)
Get the persister object for a collection role.
|
Set<String> |
getCollectionRolesByEntityParticipant(String entityName)
Retrieves a set of all the collection roles in which the given entity
is a participant, as either an index or an element.
|
ConnectionProvider |
getConnectionProvider()
Get the connection provider
|
Session |
getCurrentSession()
Obtains the current session.
|
Set |
getDefinedFilterNames()
Obtain a set of the names of all filters defined on this SessionFactory.
|
Dialect |
getDialect()
Get the SQL dialect.
|
EntityNotFoundDelegate |
getEntityNotFoundDelegate() |
EntityPersister |
getEntityPersister(String entityName)
Get the persister for the named entity
|
EventListeners |
getEventListeners() |
SessionFactoryObserver |
getFactoryObserver()
Return the SessionFactoryObserver attached to the SessionFactory if any
|
FetchProfile |
getFetchProfile(String name)
Retrieve fetch profile by name.
|
FilterDefinition |
getFilterDefinition(String filterName)
Obtain the definition of a filter by name.
|
IdentifierGenerator |
getIdentifierGenerator(String rootEntityName)
Get the identifier generator for the hierarchy
|
IdentifierGeneratorFactory |
getIdentifierGeneratorFactory()
Allow access to the id generator factory, though this is only needed/allowed from configuration.
|
String |
getIdentifierPropertyName(String className) |
Type |
getIdentifierType(String className) |
String[] |
getImplementors(String className)
Return the names of all persistent (mapped) classes that extend or implement the
given class or interface, accounting for implicit/explicit polymorphism settings
and excluding mapped subclasses/joined-subclasses of other classes in the result.
|
String |
getImportedClassName(String className)
Get a class name, using query language imports
|
Interceptor |
getInterceptor()
Get the factory scoped interceptor for this factory.
|
NamedQueryDefinition |
getNamedQuery(String queryName) |
NamedSQLQueryDefinition |
getNamedSQLQuery(String queryName) |
Properties |
getProperties()
Get a copy of the Properties used to configure this session factory.
|
QueryCache |
getQueryCache()
Get the default query cache
|
QueryCache |
getQueryCache(String regionName)
Get a particular named query cache, or the default cache
|
QueryPlanCache |
getQueryPlanCache() |
Reference |
getReference() |
Type |
getReferencedPropertyType(String className,
String propertyName) |
ResultSetMappingDefinition |
getResultSetMapping(String resultSetName) |
String[] |
getReturnAliases(String queryString)
Get the return aliases of a query
|
Type[] |
getReturnTypes(String queryString)
Get the return types of a query
|
Region |
getSecondLevelCacheRegion(String regionName)
Get a named second-level cache region
|
Settings |
getSettings() |
SQLExceptionConverter |
getSQLExceptionConverter()
Retrieves the SQLExceptionConverter in effect for this SessionFactory.
|
SQLFunctionRegistry |
getSqlFunctionRegistry() |
Statistics |
getStatistics()
Retrieve the statistics fopr this factory.
|
StatisticsImplementor |
getStatisticsImplementor()
Statistics SPI
|
TransactionFactory |
getTransactionFactory() |
TransactionManager |
getTransactionManager()
Get the JTA transaction manager
|
TypeHelper |
getTypeHelper()
Retrieve this factory's
TypeHelper |
TypeResolver |
getTypeResolver()
Retrieve the
Type resolver associated with this factory. |
UpdateTimestampsCache |
getUpdateTimestampsCache()
Get the cache of table update timestamps
|
boolean |
isClosed()
Is this factory already closed?
|
Iterator |
iterateEntityNameResolvers(EntityMode entityMode) |
Session |
openSession()
Open a
Session. |
Session |
openSession(Connection connection)
Open a
Session, utilizing the specfied JDBC Connection. |
Session |
openSession(Connection connection,
boolean flushBeforeCompletionEnabled,
boolean autoCloseSessionEnabled,
ConnectionReleaseMode connectionReleaseMode)
Open a session conforming to the given parameters.
|
Session |
openSession(Connection connection,
Interceptor sessionLocalInterceptor)
|
Session |
openSession(Interceptor sessionLocalInterceptor)
Open a
Session, utilizing the specified Interceptor. |
StatelessSession |
openStatelessSession()
Open a new stateless session.
|
StatelessSession |
openStatelessSession(Connection connection)
Open a new stateless session, utilizing the specified JDBC
Connection. |
Session |
openTemporarySession()
Get a nontransactional "current" session for Hibernate EntityManager
|
void |
registerEntityNameResolver(EntityNameResolver resolver,
EntityMode entityMode) |
public SessionFactoryImpl(Configuration cfg, Mapping mapping, Settings settings, EventListeners listeners, SessionFactoryObserver observer) throws HibernateException
HibernateExceptionpublic Properties getProperties()
SessionFactoryImplementorgetProperties in interface SessionFactoryImplementorpublic IdentifierGeneratorFactory getIdentifierGeneratorFactory()
MappinggetIdentifierGeneratorFactory in interface Mappingpublic TypeResolver getTypeResolver()
SessionFactoryImplementorType resolver associated with this factory.getTypeResolver in interface SessionFactoryImplementorpublic void registerEntityNameResolver(EntityNameResolver resolver, EntityMode entityMode)
public Iterator iterateEntityNameResolvers(EntityMode entityMode)
public QueryPlanCache getQueryPlanCache()
getQueryPlanCache in interface SessionFactoryImplementorpublic StatelessSession openStatelessSession()
SessionFactoryopenStatelessSession in interface SessionFactorypublic StatelessSession openStatelessSession(Connection connection)
SessionFactoryConnection.openStatelessSession in interface SessionFactoryconnection - Connection provided by the application.public Session openSession(Connection connection, Interceptor sessionLocalInterceptor)
SessionFactorySession, 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.
openSession in interface SessionFactoryconnection - a connection provided by the application.sessionLocalInterceptor - a session-scoped interceptorpublic Session openSession(Interceptor sessionLocalInterceptor) throws HibernateException
SessionFactorySession, utilizing the specified Interceptor.
JDBC connection(s will be obtained from the
configured ConnectionProvider as needed
to perform requested work.openSession in interface SessionFactorysessionLocalInterceptor - a session-scoped interceptorHibernateException - Indicates a peroblem opening the session; pretty rare here.public Session openSession(Connection connection)
SessionFactorySession, 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.
openSession in interface SessionFactoryconnection - a connection provided by the application.public Session openSession() throws HibernateException
SessionFactorySession.
JDBC connection(s will be obtained from the
configured ConnectionProvider as needed
to perform requested work.openSession in interface SessionFactoryHibernateException - Indicates a peroblem opening the session; pretty rare here.public Session openTemporarySession() throws HibernateException
SessionFactoryImplementoropenTemporarySession in interface SessionFactoryImplementorHibernateExceptionpublic Session openSession(Connection connection, boolean flushBeforeCompletionEnabled, boolean autoCloseSessionEnabled, ConnectionReleaseMode connectionReleaseMode) throws HibernateException
SessionFactoryImplementorJTASessionContext for current session processing.openSession in interface SessionFactoryImplementorconnection - The external jdbc connection to use, if one (i.e., optional).flushBeforeCompletionEnabled - Should the session be auto-flushed
prior to transaction completion?autoCloseSessionEnabled - Should the session be auto-closed after
transaction completion?connectionReleaseMode - The release mode for managed jdbc connections.HibernateExceptionpublic Session getCurrentSession() throws HibernateException
SessionFactoryCurrentSessionContext 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.getCurrentSession in interface SessionFactoryHibernateException - Indicates an issue locating a suitable current session.public EntityPersister getEntityPersister(String entityName) throws MappingException
SessionFactoryImplementorgetEntityPersister in interface SessionFactoryImplementorentityName - The name of the entity for which to retrieve the persister.MappingException - Indicates persister could not be found with that name.public CollectionPersister getCollectionPersister(String role) throws MappingException
SessionFactoryImplementorgetCollectionPersister in interface SessionFactoryImplementorrole - The role (name) of the collection for which to retrieve the
persister.MappingException - Indicates persister could not be found with that role.public Settings getSettings()
getSettings in interface SessionFactoryImplementorpublic Dialect getDialect()
SessionFactoryImplementorSessionFactoryImplementor.getSettings().Settings.getDialect()getDialect in interface SessionFactoryImplementorpublic Interceptor getInterceptor()
SessionFactoryImplementorgetInterceptor in interface SessionFactoryImplementorpublic TransactionFactory getTransactionFactory()
public TransactionManager getTransactionManager()
SessionFactoryImplementorgetTransactionManager in interface SessionFactoryImplementorpublic SQLExceptionConverter getSQLExceptionConverter()
SessionFactoryImplementorgetSQLExceptionConverter in interface SessionFactoryImplementorpublic Set<String> getCollectionRolesByEntityParticipant(String entityName)
SessionFactoryImplementorgetCollectionRolesByEntityParticipant in interface SessionFactoryImplementorentityName - The entity name for which to get the collection roles.public Reference getReference() throws NamingException
getReference in interface ReferenceableNamingExceptionpublic NamedQueryDefinition getNamedQuery(String queryName)
getNamedQuery in interface SessionFactoryImplementorpublic NamedSQLQueryDefinition getNamedSQLQuery(String queryName)
getNamedSQLQuery in interface SessionFactoryImplementorpublic ResultSetMappingDefinition getResultSetMapping(String resultSetName)
getResultSetMapping in interface SessionFactoryImplementorpublic Type getIdentifierType(String className) throws MappingException
getIdentifierType in interface MappingMappingExceptionpublic String getIdentifierPropertyName(String className) throws MappingException
getIdentifierPropertyName in interface MappingMappingExceptionpublic Type[] getReturnTypes(String queryString) throws HibernateException
SessionFactoryImplementorgetReturnTypes in interface SessionFactoryImplementorHibernateExceptionpublic String[] getReturnAliases(String queryString) throws HibernateException
SessionFactoryImplementorgetReturnAliases in interface SessionFactoryImplementorHibernateExceptionpublic ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException
SessionFactoryClassMetadata associated with the given entity class.getClassMetadata in interface SessionFactorypersistentClass - The entity classHibernateException - Generally null is returned instead of throwing.public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException
SessionFactoryCollectionMetadata associated with the named collection role.getCollectionMetadata in interface SessionFactoryroleName - The collection role (in form [owning-entity-name].[collection-property-name]).HibernateException - Generally null is returned instead of throwing.public ClassMetadata getClassMetadata(String entityName) throws HibernateException
SessionFactoryClassMetadata associated with the given entity class.getClassMetadata in interface SessionFactoryentityName - The entity classHibernateException - Generally null is returned instead of throwing.public String[] getImplementors(String className) throws MappingException
getImplementors in interface SessionFactoryImplementorMappingExceptionpublic String getImportedClassName(String className)
SessionFactoryImplementorgetImportedClassName in interface SessionFactoryImplementorpublic Map<String,ClassMetadata> getAllClassMetadata() throws HibernateException
SessionFactoryClassMetadata for all mapped entities.getAllClassMetadata in interface SessionFactoryClassMetadata keyed by the
corresponding String entity-name.HibernateException - Generally empty map is returned instead of throwing.public Map getAllCollectionMetadata() throws HibernateException
SessionFactoryCollectionMetadata for all mapped collectionsgetAllCollectionMetadata in interface SessionFactoryHibernateException - Generally empty map is returned instead of throwing.public Type getReferencedPropertyType(String className, String propertyName) throws MappingException
getReferencedPropertyType in interface MappingMappingExceptionpublic ConnectionProvider getConnectionProvider()
SessionFactoryImplementorgetConnectionProvider in interface SessionFactoryImplementorpublic void close()
throws HibernateException
close in interface SessionFactoryHibernateException - Indicates an issue closing the factory.public Cache getCache()
SessionFactorygetCache in interface SessionFactorypublic void evictEntity(String entityName, Serializable id) throws HibernateException
SessionFactoryevictEntity in interface SessionFactoryentityName - The entity name for which to evict data.id - The entity idHibernateException - Generally will mean that either that
'persisttentClass' did not name a mapped entity or a problem
communicating with underlying cache impl.public void evictEntity(String entityName) throws HibernateException
SessionFactoryevictEntity in interface SessionFactoryentityName - The entity name for which to evict data.HibernateException - Generally will mean that either that
'persisttentClass' did not name a mapped entity or a problem
communicating with underlying cache impl.public void evict(Class persistentClass, Serializable id) throws HibernateException
SessionFactoryevict in interface SessionFactorypersistentClass - The entity class for which to evict data.id - The entity idHibernateException - Generally will mean that either that
'persisttentClass' did not name a mapped entity or a problem
communicating with underlying cache impl.public void evict(Class persistentClass) throws HibernateException
SessionFactoryevict in interface SessionFactorypersistentClass - The entity class for which to evict data.HibernateException - Generally will mean that either that
'persisttentClass' did not name a mapped entity or a problem
communicating with underlying cache impl.public void evictCollection(String roleName, Serializable id) throws HibernateException
SessionFactoryevictCollection in interface SessionFactoryroleName - The name of the collection roleid - The id of the collection ownerHibernateException - Generally will mean that either that
'roleName' did not name a mapped collection or a problem
communicating with underlying cache impl.public void evictCollection(String roleName) throws HibernateException
SessionFactoryevictCollection in interface SessionFactoryroleName - The name of the collection role whose regions should be evictedHibernateException - Generally will mean that either that
'roleName' did not name a mapped collection or a problem
communicating with underlying cache impl.public void evictQueries()
throws HibernateException
SessionFactoryevictQueries in interface SessionFactoryHibernateException - Indicate a problem communicating with
underlying cache impl.public void evictQueries(String regionName) throws HibernateException
SessionFactoryevictQueries in interface SessionFactoryregionName - The named query cache region from which to evict.HibernateException - Since a not-found 'cacheRegion' simply no-ops,
this should indicate a problem communicating with underlying cache impl.public UpdateTimestampsCache getUpdateTimestampsCache()
SessionFactoryImplementorgetUpdateTimestampsCache in interface SessionFactoryImplementorpublic QueryCache getQueryCache()
SessionFactoryImplementorgetQueryCache in interface SessionFactoryImplementorpublic QueryCache getQueryCache(String regionName) throws HibernateException
SessionFactoryImplementorgetQueryCache in interface SessionFactoryImplementorregionName - the name of the cache region, or null for the default query cacheHibernateExceptionpublic Region getSecondLevelCacheRegion(String regionName)
SessionFactoryImplementorgetSecondLevelCacheRegion in interface SessionFactoryImplementorregionName - The name of the region to retrieve.public Map getAllSecondLevelCacheRegions()
SessionFactoryImplementorRegion instances as the values.getAllSecondLevelCacheRegions in interface SessionFactoryImplementorpublic boolean isClosed()
SessionFactoryisClosed in interface SessionFactorypublic Statistics getStatistics()
SessionFactorygetStatistics in interface SessionFactorypublic StatisticsImplementor getStatisticsImplementor()
SessionFactoryImplementorgetStatisticsImplementor in interface SessionFactoryImplementorpublic FilterDefinition getFilterDefinition(String filterName) throws HibernateException
SessionFactorygetFilterDefinition in interface SessionFactoryfilterName - The name of the filter for which to obtain the definition.HibernateException - If no filter defined with the given name.public boolean containsFetchProfileDefinition(String name)
SessionFactorycontainsFetchProfileDefinition in interface SessionFactoryname - The name to checkpublic Set getDefinedFilterNames()
SessionFactorygetDefinedFilterNames in interface SessionFactorypublic BatcherFactory getBatcherFactory()
public IdentifierGenerator getIdentifierGenerator(String rootEntityName)
SessionFactoryImplementorgetIdentifierGenerator in interface SessionFactoryImplementorpublic EventListeners getEventListeners()
public EntityNotFoundDelegate getEntityNotFoundDelegate()
getEntityNotFoundDelegate in interface SessionFactoryImplementorpublic SQLFunctionRegistry getSqlFunctionRegistry()
getSqlFunctionRegistry in interface SessionFactoryImplementorpublic FetchProfile getFetchProfile(String name)
SessionFactoryImplementorgetFetchProfile in interface SessionFactoryImplementorname - The name of the profile to retrieve.public SessionFactoryObserver getFactoryObserver()
SessionFactoryImplementorgetFactoryObserver in interface SessionFactoryImplementorpublic TypeHelper getTypeHelper()
SessionFactoryTypeHelpergetTypeHelper in interface SessionFactoryTypeHelperCopyright © 2002-2017 Red Hat Middleware, LLC. All Rights Reserved