Top Description Inners Fields Constructors Methods
org.hibernate.internal

public Class SessionFactoryImpl

extends QueryParameterBindingTypeResolverImpl
implements SessionFactoryImplementor
Class Inheritance
All Implemented Interfaces
org.hibernate.engine.spi.SessionFactoryImplementor, org.hibernate.query.spi.QueryParameterBindingTypeResolver, org.hibernate.sql.ast.spi.SqlAstCreationContext, org.hibernate.query.sqm.spi.SqmCreationContext, org.hibernate.SessionFactory, java.io.Closeable, java.lang.AutoCloseable, java.io.Serializable, javax.naming.Referenceable, jakarta.persistence.EntityManagerFactory, org.hibernate.engine.spi.Mapping
Imports
java.io.IOException, .InvalidObjectException, .ObjectInputStream, .ObjectOutputStream, java.sql.Connection, java.util.ArrayList, .Collections, .HashMap, .HashSet, .List, .Map, .Set, .TimeZone, java.util.concurrent.ConcurrentHashMap, java.util.function.Supplier, javax.naming.Reference, .StringRefAddr, org.hibernate.CustomEntityDirtinessStrategy, .EntityNameResolver, .FlushMode, .HibernateException, .Interceptor, .MappingException, .Session, .SessionEventListener, .SessionFactory, .SessionFactoryObserver, .StatelessSession, .StatelessSessionBuilder, .UnknownFilterException, org.hibernate.binder.internal.TenantIdBinder, org.hibernate.boot.cfgxml.spi.CfgXmlAccessService, org.hibernate.boot.model.relational.SqlStringGenerationContext, org.hibernate.boot.model.relational.internal.SqlStringGenerationContextImpl, org.hibernate.boot.registry.classloading.spi.ClassLoaderService, org.hibernate.boot.spi.BootstrapContext, .MetadataImplementor, .SessionFactoryOptions, org.hibernate.cache.cfg.internal.DomainDataRegionConfigImpl, org.hibernate.cache.cfg.spi.DomainDataRegionConfig, org.hibernate.cache.spi.CacheImplementor, org.hibernate.cache.spi.access.AccessType, org.hibernate.cfg.AvailableSettings, org.hibernate.context.internal.JTASessionContext, .ManagedSessionContext, .ThreadLocalSessionContext, org.hibernate.context.spi.CurrentSessionContext, .CurrentTenantIdentifierResolver, org.hibernate.dialect.Dialect, org.hibernate.engine.config.spi.ConfigurationService, org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess, org.hibernate.engine.jdbc.spi.JdbcServices, org.hibernate.engine.profile.FetchProfile, org.hibernate.engine.spi.FilterDefinition, .SessionBuilderImplementor, .SessionFactoryImplementor, .SessionImplementor, org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform, org.hibernate.event.spi.EventEngine, org.hibernate.generator.Generator, org.hibernate.graph.spi.RootGraphImplementor, org.hibernate.id.IdentifierGenerator, org.hibernate.id.factory.IdentifierGeneratorFactory, org.hibernate.integrator.spi.Integrator, .IntegratorService, org.hibernate.jpa.internal.ExceptionMapperLegacyJpaImpl, .PersistenceUnitUtilImpl, org.hibernate.mapping.Collection, .PersistentClass, .RootClass, org.hibernate.metadata.CollectionMetadata, org.hibernate.metamodel.internal.RuntimeMetamodelsImpl, org.hibernate.metamodel.mapping.JdbcMapping, org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl, org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor, org.hibernate.metamodel.spi.MappingMetamodelImplementor, .MetamodelImplementor, .RuntimeMetamodelsImplementor, .RuntimeModelCreationContext, org.hibernate.persister.entity.SessionFactoryBasedWrapperOptions, org.hibernate.procedure.spi.ProcedureCallImplementor, org.hibernate.proxy.EntityNotFoundDelegate, .LazyInitializer, org.hibernate.query.hql.spi.SqmQueryImplementor, org.hibernate.query.internal.QueryEngineImpl, org.hibernate.query.named.NamedObjectRepository, .NamedQueryMemento, org.hibernate.query.spi.QueryEngine, .QueryImplementor, org.hibernate.query.sql.spi.NativeQueryImplementor, org.hibernate.query.sqm.NodeBuilder, org.hibernate.query.sqm.function.SqmFunctionRegistry, org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableStrategy, .LocalTemporaryTableStrategy, .PersistentTableStrategy, org.hibernate.query.sqm.spi.NamedSqmQueryMemento, org.hibernate.relational.SchemaManager, org.hibernate.relational.internal.SchemaManagerImpl, org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode, .StatementInspector, org.hibernate.resource.transaction.backend.jta.internal.synchronization.ExceptionMapper, org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder, org.hibernate.service.ServiceRegistry, org.hibernate.service.spi.ServiceRegistryImplementor, .SessionFactoryServiceRegistry, .SessionFactoryServiceRegistryFactory, org.hibernate.stat.spi.StatisticsImplementor, org.hibernate.type.Type, org.hibernate.type.descriptor.WrapperOptions, org.hibernate.type.descriptor.java.JavaType, org.hibernate.type.spi.TypeConfiguration, org.jboss.logging.Logger, jakarta.persistence.EntityGraph, .PersistenceException, .PersistenceUnitUtil, .Query, .SynchronizationType

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

Concrete implementation of the SessionFactory API.

Exposes two interfaces:

This class is thread-safe.

Implementation Note

This class must appear immutable to clients, even if it does all kinds of caching and pooling under the covers. It is crucial that the class is not only thread-safe, but also highly concurrent. Synchronization must be used extremely sparingly.

Authors
Gavin King, Steve Ebersole, Chris Cranford

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
public static class
public static class
private static enum

Field Summary

Modifier and TypeField and Description
private final transient CacheImplementor
private final transient CurrentSessionContext
private final transient SessionFactoryImpl.SessionBuilderImpl
private final transient StatelessSessionBuilder
private final transient EntityNameResolver
private final transient EventEngine
private final transient FastSessionServices
private final transient Map<String, FetchProfile>
private final transient Map<String, FilterDefinition>
private final transient Map<String, Generator>
private final transient JdbcServices
private final PersistenceUnitUtil
private static final CoreMessageLogger
private final String
private final transient SessionFactoryObserverChain
private final transient QueryEngine
private final transient RuntimeMetamodelsImplementor
private final transient SchemaManager
private final transient SessionFactoryServiceRegistry
private final transient SessionFactoryOptions
private final transient Map<String, Object>
private final transient SqlStringGenerationContext
private transient StatisticsImplementor
private transient volatile SessionFactoryImpl.Status
private final transient SessionFactoryImpl.SessionBuilderImpl
private final transient JavaType<Object>
private final String
private final transient WrapperOptions

Constructor Summary

AccessConstructor and Description
public
SessionFactoryImpl(MetadataImplementor bootMetamodel, SessionFactoryOptions options)

Deprecated for removal since 6.2. This constructor will be removed
public
SessionFactoryImpl(final MetadataImplementor bootMetamodel, final SessionFactoryOptions options, final BootstrapContext bootstrapContext)

Deprecated as a consequence of MetadataImplementor being deprecated.

Method Summary

Modifier and TypeMethod and Description
public <T> void
addNamedEntityGraph(String
name for the entity graph
graphName
,
EntityGraph<T>
entity graph
entityGraph
)

Implements jakarta.persistence.EntityManagerFactory.addNamedEntityGraph.

Add a named copy of the EntityGraph to the EntityManagerFactory.
public void
addNamedQuery(String
name for the query
name
,
Query
Query, TypedQuery, or StoredProcedureQuery object
query
)

Implements jakarta.persistence.EntityManagerFactory.addNamedQuery.

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.
public void
public String
bestGuessEntityName(Object object)

Implements org.hibernate.engine.spi.SessionFactoryImplementor.bestGuessEntityName.

The best guess entity name for an entity not in an association
private CurrentSessionContext
private <K, V> Session
buildEntityManager(final SynchronizationType synchronizationType, final Map<K, V> map)

private SessionFactoryImpl.SessionBuilderImpl
private boolean
public void
close()

Implements org.hibernate.SessionFactory.close.

Closes the session factory, releasing all held resources.
public static Interceptor
public static Interceptor
configuredInterceptor(Interceptor interceptor, boolean explicitNoInterceptor, SessionFactoryOptions options)

public boolean
containsFetchProfileDefinition(String
The name to check
name
)

Overrides default org.hibernate.SessionFactory.containsFetchProfileDefinition.

Determine if there is a fetch profile definition registered under the given name.
private SessionFactoryImpl.SessionBuilderImpl
public Session
createEntityManager()

Implements jakarta.persistence.EntityManagerFactory.createEntityManager.

Create a new application-managed EntityManager.
public Session
createEntityManager(Map<K, V>
properties for entity manager
map
)

Implements jakarta.persistence.EntityManagerFactory.createEntityManager.

Create a new application-managed EntityManager with the specified Map of properties.
public Session
createEntityManager(SynchronizationType
how and when the entity manager should be synchronized with the current JTA transaction
synchronizationType
)

Implements jakarta.persistence.EntityManagerFactory.createEntityManager.

Create a new JTA application-managed EntityManager with the specified synchronization type.
public Session
createEntityManager(SynchronizationType
how and when the entity manager should be synchronized with the current JTA transaction
synchronizationType
,
Map<K, V>
properties for entity manager
map
)

Implements jakarta.persistence.EntityManagerFactory.createEntityManager.

Create a new JTA application-managed EntityManager with the specified synchronization type and map of properties.
private static Map<String, Generator>
createGenerators(JdbcServices jdbcServices, SqlStringGenerationContext sqlStringGenerationContext, MetadataImplementor bootMetamodel, BootstrapContext bootstrapContext)

Deprecated as a consequence of MetadataImplementor being deprecated.
private CurrentSessionContext
createSessionContext(String sessionContextType)

private static SqlStringGenerationContext
createSqlStringGenerationContext(MetadataImplementor bootMetamodel, SessionFactoryOptions options, JdbcServices jdbcServices)

Deprecated as a consequence of MetadataImplementor being deprecated.
private void
pack-priv static SessionFactoryImpl

Returns:

The deserialized factory
deserialize
(ObjectInputStream
The stream from which to "read" the factory
ois
)

Deprecated as a consequence of SessionFactoryImpl being deprecated.
Custom deserialization hook used during Session deserialization.
private void
disintegrate(Exception startupException, SessionFactoryImpl.IntegratorObserver integratorObserver)

private void
public RootGraphImplementor<?>
findEntityGraphByName(String name)

Implements org.hibernate.engine.spi.SessionFactoryImplementor.findEntityGraphByName.

Return the root EntityGraph with the given name, or null if there is no graph with the given name.
public <T> List<EntityGraph<? super T>>
findEntityGraphsByType(Class<T> entityClass)

Implements org.hibernate.SessionFactory.findEntityGraphsByType.

Return all EntityGraphs registered for the given entity type.
public CacheImplementor
getCache()

Implements org.hibernate.engine.spi.SessionFactoryImplementor.getCache.

Obtain direct access to the underlying cache regions.
public CollectionMetadata
getCollectionMetadata(String roleName)

Deprecated as a consequence of CollectionMetadata being deprecated.
public NodeBuilder
public Session
getCurrentSession()

Implements org.hibernate.SessionFactory.getCurrentSession.

Obtains the current session, an instance of Session implicitly associated with some context or scope.
public CurrentTenantIdentifierResolver<Object>
public CustomEntityDirtinessStrategy
public Set<String>
public Set<String>
public SessionFactoryImplementor.DeserializationResolver<?>
public EntityNotFoundDelegate
public EventEngine
getEventEngine()

Implements org.hibernate.engine.spi.SessionFactoryImplementor.getEventEngine.

Get the EventEngine associated with this SessionFactory
public FastSessionServices
public FetchProfile
getFetchProfile(String
The name of the profile to retrieve.
name
)

Implements org.hibernate.engine.spi.SessionFactoryImplementor.getFetchProfile.

Retrieve fetch profile by name.
public FilterDefinition
getFilterDefinition(String
The name of the filter for which to obtain the definition.
filterName
)

Implements org.hibernate.engine.spi.SessionFactoryImplementor.getFilterDefinition.

Obtain the definition of a filter by name.
public Generator
getGenerator(String rootEntityName)

Implements org.hibernate.engine.spi.SessionFactoryImplementor.getGenerator.

Deprecated
Get the identifier generator for the hierarchy
public IdentifierGenerator
getIdentifierGenerator(String rootEntityName)

Implements org.hibernate.engine.spi.SessionFactoryImplementor.getIdentifierGenerator.

Deprecated
Get the identifier generator for the hierarchy
public IdentifierGeneratorFactory
public String
public Type
public Interceptor
public JdbcServices
public JpaMetamodelImplementor
public Integer
getMaximumFetchDepth()

Implements org.hibernate.sql.ast.spi.SqlAstCreationContext.getMaximumFetchDepth.

When creating org.hibernate.sql.results.graph.Fetch references, defines a limit to how deep we should join for fetches.
public MetamodelImplementor
getMetamodel()

Implements org.hibernate.engine.spi.SessionFactoryImplementor.getMetamodel.

Deprecated as a consequence of MetamodelImplementor being deprecated.
Return an instance of Metamodel interface for access to the metamodel of the persistence unit.
public String
getName()

Implements org.hibernate.engine.spi.SessionFactoryImplementor.getName.

Access to the name (if one) assigned to the SessionFactory
public PersistenceUnitUtil
getPersistenceUnitUtil()

Implements jakarta.persistence.EntityManagerFactory.getPersistenceUnitUtil.

Return interface providing access to utility methods for the persistence unit.
public Map<String, Object>
getProperties()

Implements jakarta.persistence.EntityManagerFactory.getProperties.

Get the properties and associated values that are in effect for the entity manager factory.
public QueryEngine
public Reference
getReference()

Implements javax.naming.Referenceable.getReference.

Retrieves the Reference of this object.
public Type
public RuntimeMetamodelsImplementor
public SchemaManager
getSchemaManager()

Implements org.hibernate.SessionFactory.getSchemaManager.

A SchemaManager with the same default catalog and schema as pooled connections belonging to this factory.
private static SessionFactoryServiceRegistry
getServiceRegistry(SessionFactoryOptions options, SessionFactoryImplementor self)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
public ServiceRegistryImplementor
getServiceRegistry()

Implements org.hibernate.engine.spi.SessionFactoryImplementor.getServiceRegistry.

Access to the ServiceRegistry for this SessionFactory.
private static String
public SessionFactoryOptions
private static Map<String, Object>
public SqlStringGenerationContext
public StatisticsImplementor
public JavaType<Object>
public TypeConfiguration
public String
getUuid()

Implements org.hibernate.engine.spi.SessionFactoryImplementor.getUuid.

Get the UUID for this SessionFactory.
public WrapperOptions
private void
initializeMappingModel(MappingMetamodelImpl mappingMetamodelImpl, BootstrapContext bootstrapContext, MetadataImplementor bootMetamodel, SessionFactoryOptions options)

Deprecated as a consequence of MappingMetamodelImpl and MetadataImplementor being deprecated.
private void
integrate(MetadataImplementor bootMetamodel, BootstrapContext bootstrapContext, SessionFactoryImpl.IntegratorObserver integratorObserver)

Deprecated as a consequence of MetadataImplementor being deprecated.
public boolean
isClosed()

Implements org.hibernate.SessionFactory.isClosed.

Is this factory already closed?
public boolean
isOpen()

Implements jakarta.persistence.EntityManagerFactory.isOpen.

Indicates whether the factory is open.
private static SessionFactory
private void
private void
maskOutIfSet(Map<String, Object> props, String setting)

private void
public SessionImplementor
openSession()

Implements org.hibernate.engine.spi.SessionFactoryImplementor.openSession.

Overrides SessionFactory#openSession() to widen the return type: this is useful for internal code depending on SessionFactoryImplementor as it would otherwise need to frequently resort to casting to the internal contract.
public StatelessSession
public StatelessSession
openStatelessSession(Connection
Connection provided by the application.
connection
)

Implements org.hibernate.SessionFactory.openStatelessSession.

Open a new stateless session, utilizing the specified JDBC Connection.
public SessionImpl
openTemporarySession()

Implements org.hibernate.engine.spi.SessionFactoryImplementor.openTemporarySession.

Get a non-transactional "current" session (used by hibernate-envers)
private void
primeSecondLevelCacheRegions(MetadataImplementor mappingMetadata)

Deprecated as a consequence of MetadataImplementor being deprecated.
private void
readObject(ObjectInputStream
The stream from which the object is being deserialized.
in
)

Custom serialization hook used when the factory is directly deserialized.

private Object

Returns:

The resolved factory to use.
readResolve
()

Custom serialization hook used when the factory is directly deserialized.

private RuntimeModelCreationContext
runtimeModelCreationContext(BootstrapContext bootstrapContext, MetadataImplementor bootMetamodel, MappingMetamodelImplementor mappingMetamodel, TypeConfiguration typeConfiguration, SessionFactoryOptions options)

Deprecated as a consequence of MetadataImplementor and RuntimeModelCreationContext being deprecated.
pack-priv void
serialize(ObjectOutputStream
The stream to which to write the factory
oos
)

Custom serialization hook used during Session serialization.

public <T> T
unwrap(Class<T>
the class of the object to be returned. This is normally either the underlying EntityManagerFactory implementation class or an interface that it implements.
type
)

Implements jakarta.persistence.EntityManagerFactory.unwrap.

Return an object of the specified type to allow access to the provider-specific API.
protected void
public SessionFactoryImpl.SessionBuilderImpl
withOptions()

Implements org.hibernate.engine.spi.SessionFactoryImplementor.withOptions.

Obtain a session builder for creating new Sessions with certain customized options.
public StatelessSessionBuilder
private void
writeObject(ObjectOutputStream
The stream into which the object is being serialized.
out
)

Custom serialization hook used when the factory is directly serialized

Inherited from org.hibernate.internal.QueryParameterBindingTypeResolverImpl:
resolveParameterBindTyperesolveParameterBindType