public final class SessionFactoryImpl extends Object implements SessionFactoryImplementor
Modifier and Type | Class and Description |
---|---|
static class |
SessionFactoryImpl.StatelessSessionBuilderImpl |
SessionFactoryImplementor.DeserializationResolver<T extends SessionFactoryImplementor>
Constructor and Description |
---|
SessionFactoryImpl(BootstrapContext bootstrapContext,
MetadataImplementor metadata,
SessionFactoryOptions options) |
Modifier and Type | Method and Description |
---|---|
<T> void |
addNamedEntityGraph(String graphName,
EntityGraph<T> entityGraph)
Add a named copy of the EntityGraph to the
EntityManagerFactory.
|
void |
addNamedQuery(String name,
Query query)
Define the query, typed query, or stored procedure query as
a named query such that future query objects can be created
from it using the
createNamedQuery or
createNamedStoredProcedureQuery method. |
void |
addObserver(SessionFactoryObserver observer) |
void |
close()
Closes the session factory, releasing all held resources.
|
static Interceptor |
configuredInterceptor(Interceptor interceptor,
SessionFactoryOptions options) |
boolean |
containsFetchProfileDefinition(String name)
Determine if this session factory contains a fetch profile definition
registered under the given name.
|
Session |
createEntityManager()
Create a new application-managed
EntityManager . |
Session |
createEntityManager(Map map)
Create a new application-managed
EntityManager with the
specified Map of properties. |
Session |
createEntityManager(SynchronizationType synchronizationType)
Create a new JTA application-managed
EntityManager with the
specified synchronization type. |
Session |
createEntityManager(SynchronizationType synchronizationType,
Map map)
Create a new JTA application-managed
EntityManager with the
specified synchronization type and map of properties. |
EntityGraph |
findEntityGraphByName(String name) |
<T> List<EntityGraph<? super T>> |
findEntityGraphsByType(Class<T> entityClass)
Find all
EntityGraph s associated with a given entity type. |
Map<String,ClassMetadata> |
getAllClassMetadata()
Retrieve the
ClassMetadata for all mapped entities. |
Map |
getAllCollectionMetadata()
Get the
CollectionMetadata for all mapped collections. |
CacheImplementor |
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. |
CriteriaBuilder |
getCriteriaBuilder()
Return an instance of
CriteriaBuilder for the creation of
CriteriaQuery objects. |
Session |
getCurrentSession()
Obtains the current session.
|
CurrentTenantIdentifierResolver |
getCurrentTenantIdentifierResolver() |
CustomEntityDirtinessStrategy |
getCustomEntityDirtinessStrategy() |
Set |
getDefinedFilterNames()
Obtain a set of the names of all filters defined on this SessionFactory.
|
SessionFactoryImplementor.DeserializationResolver |
getDeserializationResolver() |
EntityNotFoundDelegate |
getEntityNotFoundDelegate() |
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) |
Interceptor |
getInterceptor()
Get the factory scoped interceptor for this factory.
|
JdbcServices |
getJdbcServices()
Get the JdbcServices.
|
MetamodelImplementor |
getMetamodel()
Return an instance of
Metamodel interface for access to the
metamodel of the persistence unit. |
String |
getName()
Access to the name (if one) assigned to the SessionFactory
|
NamedQueryRepository |
getNamedQueryRepository()
Provides access to the named query repository
|
PersistenceUnitUtil |
getPersistenceUnitUtil()
Return interface providing access to utility methods
for the persistence unit.
|
Map<String,Object> |
getProperties()
Get the properties and associated values that are in effect
for the entity manager factory.
|
QueryPlanCache |
getQueryPlanCache()
Access to the cachres of HQL/JPQL and native query plans.
|
Reference |
getReference() |
Type |
getReferencedPropertyType(String className,
String propertyName) |
String[] |
getReturnAliases(String queryString)
Get the return aliases of a query
|
Type[] |
getReturnTypes(String queryString)
Get the return types of a query
|
ServiceRegistryImplementor |
getServiceRegistry()
Access to the ServiceRegistry for this SessionFactory.
|
SessionFactoryOptions |
getSessionFactoryOptions()
Get the special options used to build the factory.
|
Settings |
getSettings() |
SQLFunctionRegistry |
getSqlFunctionRegistry() |
StatisticsImplementor |
getStatistics()
Retrieve the statistics fopr this factory.
|
TypeHelper |
getTypeHelper()
Retrieve this factory's
TypeHelper . |
TypeResolver |
getTypeResolver()
Deprecated.
(since 5.3) No replacement, access to and handling of Types will be much different in 6.0
|
String |
getUuid()
Get the UUID for this SessionFactory.
|
boolean |
isClosed()
Is this factory already closed?
|
boolean |
isOpen()
Indicates whether the factory is open.
|
Session |
openSession()
Open a
Session . |
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 non-transactional "current" session (used by hibernate-envers)
|
Type |
resolveParameterBindType(Class clazz) |
Type |
resolveParameterBindType(Object bindValue) |
<T> T |
unwrap(Class<T> type)
Return an object of the specified type to allow access to the
provider-specific API.
|
protected void |
validateNotClosed() |
SessionBuilderImplementor |
withOptions()
Obtain a
Session builder. |
StatelessSessionBuilder |
withStatelessOptions()
Obtain a
StatelessSession builder. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCollectionPersister, getCollectionPersisters, getCollectionRolesByEntityParticipant, getDialect, getEntityPersister, getEntityPersisters, getImplementors, getImportedClassName, getNamedQuery, getNamedSQLQuery, getResultSetMapping, getSQLExceptionConverter, getSQLExceptionHelper, getStatisticsImplementor, iterateEntityNameResolvers, locateEntityPersister, locateEntityPersister, registerNamedQueryDefinition, registerNamedSQLQueryDefinition
getEntityManagerFactoryName, getEntityTypeByName, getSessionFactory
public SessionFactoryImpl(BootstrapContext bootstrapContext, MetadataImplementor metadata, SessionFactoryOptions options)
public Session openSession() throws HibernateException
SessionFactory
Session
.
JDBC connection(s
will be obtained from the
configured ConnectionProvider
as needed
to perform requested work.openSession
in interface SessionFactory
HibernateException
- Indicates a problem opening the session; pretty rare here.public Session openTemporarySession() throws HibernateException
SessionFactoryImplementor
openTemporarySession
in interface SessionFactoryImplementor
HibernateException
public Session getCurrentSession() throws HibernateException
SessionFactory
CurrentSessionContext
impl configured
for use.
Note that for backwards compatibility, if a CurrentSessionContext
is not configured but JTA is configured this will default to the JTASessionContext
impl.getCurrentSession
in interface SessionFactory
HibernateException
- Indicates an issue locating a suitable current session.public SessionBuilderImplementor withOptions()
SessionFactory
Session
builder.withOptions
in interface SessionFactoryImplementor
withOptions
in interface SessionFactory
public StatelessSessionBuilder withStatelessOptions()
SessionFactory
StatelessSession
builder.withStatelessOptions
in interface SessionFactory
public StatelessSession openStatelessSession()
SessionFactory
openStatelessSession
in interface SessionFactory
public StatelessSession openStatelessSession(Connection connection)
SessionFactory
Connection
.openStatelessSession
in interface SessionFactory
connection
- Connection provided by the application.public void addObserver(SessionFactoryObserver observer)
addObserver
in interface SessionFactoryImplementor
public Map<String,Object> getProperties()
EntityManagerFactory
getProperties
in interface EntityManagerFactory
protected void validateNotClosed()
public String getUuid()
SessionFactoryImplementor
UUID
, but kept
as a String.getUuid
in interface SessionFactoryImplementor
SessionFactoryRegistry.getSessionFactory(java.lang.String)
public String getName()
SessionFactoryImplementor
getName
in interface SessionFactoryImplementor
public JdbcServices getJdbcServices()
SessionFactoryImplementor
getJdbcServices
in interface SessionFactoryImplementor
public IdentifierGeneratorFactory getIdentifierGeneratorFactory()
Mapping
getIdentifierGeneratorFactory
in interface Mapping
@Deprecated public TypeResolver getTypeResolver()
Type
resolver associated with this factory.getTypeResolver
in interface SessionFactoryImplementor
public QueryPlanCache getQueryPlanCache()
SessionFactoryImplementor
getQueryPlanCache
in interface SessionFactoryImplementor
public SessionFactoryImplementor.DeserializationResolver getDeserializationResolver()
getDeserializationResolver
in interface SessionFactoryImplementor
public Settings getSettings()
getSettings
in interface SessionFactoryImplementor
public <T> List<EntityGraph<? super T>> findEntityGraphsByType(Class<T> entityClass)
HibernateEntityManagerFactory
EntityGraph
s associated with a given entity type.findEntityGraphsByType
in interface HibernateEntityManagerFactory
entityClass
- the entity type for which to find all EntityGraph
s.EntityGraph
instances associated with the given entity type. The empty list is
returned in case there are not entity graphs.public Session createEntityManager()
EntityManagerFactory
EntityManager
.
This method returns a new EntityManager
instance each time
it is invoked.
The isOpen
method will return true on the returned instance.createEntityManager
in interface EntityManagerFactory
public Session createEntityManager(Map map)
EntityManagerFactory
EntityManager
with the
specified Map of properties.
This method returns a new EntityManager
instance each time
it is invoked.
The isOpen
method will return true on the returned instance.createEntityManager
in interface EntityManagerFactory
map
- properties for entity managerpublic Session createEntityManager(SynchronizationType synchronizationType)
EntityManagerFactory
EntityManager
with the
specified synchronization type.
This method returns a new EntityManager
instance each time
it is invoked.
The isOpen
method will return true on the returned instance.createEntityManager
in interface EntityManagerFactory
synchronizationType
- how and when the entity manager should be
synchronized with the current JTA transactionpublic Session createEntityManager(SynchronizationType synchronizationType, Map map)
EntityManagerFactory
EntityManager
with the
specified synchronization type and map of properties.
This method returns a new EntityManager
instance each time
it is invoked.
The isOpen
method will return true on the returned instance.createEntityManager
in interface EntityManagerFactory
synchronizationType
- how and when the entity manager should be
synchronized with the current JTA transactionmap
- properties for entity managerpublic CriteriaBuilder getCriteriaBuilder()
EntityManagerFactory
CriteriaBuilder
for the creation of
CriteriaQuery
objects.getCriteriaBuilder
in interface EntityManagerFactory
public MetamodelImplementor getMetamodel()
EntityManagerFactory
Metamodel
interface for access to the
metamodel of the persistence unit.getMetamodel
in interface EntityManagerFactory
getMetamodel
in interface SessionFactoryImplementor
getMetamodel
in interface HibernateEntityManagerFactory
public boolean isOpen()
EntityManagerFactory
isOpen
in interface EntityManagerFactory
public EntityGraph findEntityGraphByName(String name)
findEntityGraphByName
in interface SessionFactoryImplementor
public SessionFactoryOptions getSessionFactoryOptions()
SessionFactory
getSessionFactoryOptions
in interface SessionFactory
public Interceptor getInterceptor()
SessionFactoryImplementor
getInterceptor
in interface SessionFactoryImplementor
public Reference getReference()
getReference
in interface Referenceable
public NamedQueryRepository getNamedQueryRepository()
SessionFactoryImplementor
getNamedQueryRepository
in interface SessionFactoryImplementor
public Type getIdentifierType(String className) throws MappingException
getIdentifierType
in interface Mapping
MappingException
public String getIdentifierPropertyName(String className) throws MappingException
getIdentifierPropertyName
in interface Mapping
MappingException
public Type[] getReturnTypes(String queryString) throws HibernateException
SessionFactoryImplementor
getReturnTypes
in interface SessionFactoryImplementor
HibernateException
public String[] getReturnAliases(String queryString) throws HibernateException
SessionFactoryImplementor
getReturnAliases
in interface SessionFactoryImplementor
HibernateException
public ClassMetadata getClassMetadata(Class persistentClass) throws HibernateException
SessionFactory
ClassMetadata
associated with the given entity class.getClassMetadata
in interface SessionFactory
persistentClass
- The entity classHibernateException
- Generally null is returned instead of throwing.public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException
SessionFactory
CollectionMetadata
associated with the named collection role.getCollectionMetadata
in interface SessionFactory
roleName
- 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
SessionFactory
ClassMetadata
associated with the given entity class.getClassMetadata
in interface SessionFactory
entityName
- The entity classHibernateException
- Generally null is returned instead of throwing.public Map<String,ClassMetadata> getAllClassMetadata() throws HibernateException
SessionFactory
ClassMetadata
for all mapped entities.getAllClassMetadata
in interface SessionFactory
ClassMetadata
keyed by the
corresponding String
entity-name.HibernateException
- Generally empty map is returned instead of throwing.public Map getAllCollectionMetadata() throws HibernateException
SessionFactory
CollectionMetadata
for all mapped collections.getAllCollectionMetadata
in interface SessionFactory
HibernateException
- Generally empty map is returned instead of throwing.public Type getReferencedPropertyType(String className, String propertyName) throws MappingException
getReferencedPropertyType
in interface Mapping
MappingException
public void close() throws HibernateException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface EntityManagerFactory
close
in interface SessionFactory
HibernateException
public CacheImplementor getCache()
SessionFactory
getCache
in interface EntityManagerFactory
getCache
in interface SessionFactoryImplementor
getCache
in interface SessionFactory
public PersistenceUnitUtil getPersistenceUnitUtil()
EntityManagerFactory
getPersistenceUnitUtil
in interface EntityManagerFactory
PersistenceUnitUtil
interfacepublic void addNamedQuery(String name, Query query)
EntityManagerFactory
createNamedQuery
or
createNamedStoredProcedureQuery
method.
Any configuration of the query object (except for actual parameter binding) in effect when the named query is added is retained as part of the named query definition. This includes configuration information such as max results, hints, flush mode, lock mode, result set mapping information, and information about stored procedure parameters.
When the query is executed, information that can be set
by means of the query APIs can be overridden. Information
that is overridden does not affect the named query as
registered with the entity manager factory, and thus does
not affect subsequent query objects created from it by
means of the createNamedQuery
or
createNamedStoredProcedureQuery
method.
If a named query of the same name has been previously defined, either statically via metadata or via this method, that query definition is replaced.
addNamedQuery
in interface EntityManagerFactory
name
- name for the queryquery
- Query, TypedQuery, or StoredProcedureQuery objectpublic <T> T unwrap(Class<T> type)
EntityManagerFactory
unwrap
in interface EntityManagerFactory
type
- the class of the object to be returned. This is
normally either the underlying EntityManagerFactory
implementation class or an interface that it implements.public <T> void addNamedEntityGraph(String graphName, EntityGraph<T> entityGraph)
EntityManagerFactory
addNamedEntityGraph
in interface EntityManagerFactory
graphName
- name for the entity graphentityGraph
- entity graphpublic boolean isClosed()
SessionFactory
isClosed
in interface SessionFactory
public StatisticsImplementor getStatistics()
SessionFactory
getStatistics
in interface SessionFactoryImplementor
getStatistics
in interface SessionFactory
public FilterDefinition getFilterDefinition(String filterName) throws HibernateException
SessionFactory
getFilterDefinition
in interface SessionFactory
filterName
- 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)
SessionFactory
containsFetchProfileDefinition
in interface SessionFactory
name
- The name to checkpublic Set getDefinedFilterNames()
SessionFactory
getDefinedFilterNames
in interface SessionFactory
public IdentifierGenerator getIdentifierGenerator(String rootEntityName)
SessionFactoryImplementor
getIdentifierGenerator
in interface SessionFactoryImplementor
public ServiceRegistryImplementor getServiceRegistry()
SessionFactoryImplementor
getServiceRegistry
in interface SessionFactoryImplementor
public EntityNotFoundDelegate getEntityNotFoundDelegate()
getEntityNotFoundDelegate
in interface SessionFactoryImplementor
public SQLFunctionRegistry getSqlFunctionRegistry()
getSqlFunctionRegistry
in interface SessionFactoryImplementor
public FetchProfile getFetchProfile(String name)
SessionFactoryImplementor
getFetchProfile
in interface SessionFactoryImplementor
name
- The name of the profile to retrieve.public TypeHelper getTypeHelper()
SessionFactory
TypeHelper
.getTypeHelper
in interface SessionFactory
TypeHelper
public Type resolveParameterBindType(Object bindValue)
resolveParameterBindType
in interface QueryParameterBindingTypeResolver
public Type resolveParameterBindType(Class clazz)
resolveParameterBindType
in interface QueryParameterBindingTypeResolver
public static Interceptor configuredInterceptor(Interceptor interceptor, SessionFactoryOptions options)
public CustomEntityDirtinessStrategy getCustomEntityDirtinessStrategy()
getCustomEntityDirtinessStrategy
in interface SessionFactoryImplementor
public CurrentTenantIdentifierResolver getCurrentTenantIdentifierResolver()
getCurrentTenantIdentifierResolver
in interface SessionFactoryImplementor
Copyright © 2021 JBoss by Red Hat. All rights reserved.