Top Description Fields Constructors Methods
org.hibernate.internal

public abstract Class AbstractSharedSessionContract

extends Object
implements SharedSessionContractImplementor
Class Inheritance
All Implemented Interfaces
org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.type.descriptor.java.JavaType.CoercionContext, org.hibernate.query.spi.QueryProducerImplementor, org.hibernate.query.QueryProducer, org.hibernate.type.descriptor.WrapperOptions, org.hibernate.engine.jdbc.LobCreationContext, org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder.Options, org.hibernate.resource.jdbc.spi.JdbcSessionOwner, org.hibernate.SharedSessionContract, java.io.Serializable, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
org.hibernate.internal.SessionImpl, org.hibernate.internal.StatelessSessionImpl
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, java.sql.SQLException, java.util.List, .Locale, .Map, .Objects, .TimeZone, .UUID, java.util.function.Function, jakarta.persistence.EntityGraph, .FlushModeType, .NamedNativeQuery, .TransactionRequiredException, .Tuple, org.hibernate.CacheMode, .EntityNameResolver, .FlushMode, .HibernateException, .Interceptor, .LockMode, .SessionEventListener, .SessionException, .Transaction, .UnknownEntityTypeException, org.hibernate.binder.internal.TenantIdBinder, org.hibernate.cache.spi.CacheTransactionSynchronization, org.hibernate.context.spi.CurrentTenantIdentifierResolver, org.hibernate.engine.internal.SessionEventListenerManagerImpl, org.hibernate.engine.jdbc.LobCreator, org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess, org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl, org.hibernate.engine.jdbc.spi.JdbcCoordinator, .JdbcServices, org.hibernate.engine.spi.EntityKey, .ExceptionConverter, .LoadQueryInfluencers, .SessionEventListenerManager, .SessionFactoryImplementor, .SharedSessionContractImplementor, org.hibernate.engine.transaction.internal.TransactionImpl, org.hibernate.engine.transaction.spi.TransactionImplementor, org.hibernate.event.spi.EventManager, org.hibernate.graph.RootGraph, org.hibernate.graph.internal.RootGraphImpl, org.hibernate.graph.spi.RootGraphImplementor, org.hibernate.id.uuid.StandardRandomStrategy, org.hibernate.jdbc.ReturningWork, .Work, .WorkExecutorVisitable, org.hibernate.jpa.spi.NativeQueryConstructorTransformer, .NativeQueryListTransformer, .NativeQueryMapTransformer, .NativeQueryTupleTransformer, org.hibernate.metamodel.model.domain.ManagedDomainType, org.hibernate.persister.entity.EntityPersister, org.hibernate.procedure.ProcedureCall, org.hibernate.procedure.internal.ProcedureCallImpl, org.hibernate.procedure.spi.NamedCallableQueryMemento, org.hibernate.query.IllegalMutationQueryException, .IllegalNamedQueryOptionsException, .IllegalSelectQueryException, .MutationQuery, .Query, .QueryTypeMismatchException, .SelectionQuery, .UnknownNamedQueryException, org.hibernate.query.criteria.CriteriaDefinition, .HibernateCriteriaBuilder, .JpaCriteriaInsertSelect, org.hibernate.query.hql.spi.SqmQueryImplementor, org.hibernate.query.named.NamedResultSetMappingMemento, org.hibernate.query.spi.HqlInterpretation, .QueryEngine, .QueryImplementor, org.hibernate.query.sql.internal.NativeQueryImpl, org.hibernate.query.sql.spi.NamedNativeQueryMemento, .NativeQueryImplementor, org.hibernate.query.sqm.SqmSelectionQuery, org.hibernate.query.sqm.internal.QuerySqmImpl, .SqmSelectionQueryImpl, .SqmUtil, org.hibernate.query.sqm.spi.NamedSqmQueryMemento, org.hibernate.query.sqm.tree.SqmDmlStatement, .SqmStatement, org.hibernate.query.sqm.tree.delete.SqmDeleteStatement, org.hibernate.query.sqm.tree.insert.SqmInsertSelectStatement, org.hibernate.query.sqm.tree.select.SqmQueryGroup, .SqmQuerySpec, .SqmSelectStatement, org.hibernate.query.sqm.tree.update.SqmUpdateStatement, org.hibernate.resource.jdbc.internal.EmptyStatementInspector, org.hibernate.resource.jdbc.spi.JdbcSessionContext, .PhysicalConnectionHandlingMode, .StatementInspector, org.hibernate.resource.transaction.TransactionRequiredForJoinException, org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorImpl, org.hibernate.resource.transaction.spi.TransactionCoordinator, .TransactionCoordinatorBuilder, jakarta.persistence.criteria.CriteriaDelete, .CriteriaQuery, .CriteriaUpdate

Base class for implementations of org.hibernate.SharedSessionContract and SharedSessionContractImplementor. Intended for concrete implementations of org.hibernate.Session and org.hibernate.StatelessSession.

Implementation Note

A Session or JPA EntityManager is a single-threaded object, which may not be called concurrently. Therefore, this implementation defines access to a number of instance state values in a manner that is not exactly thread-safe.

Author
Steve Ebersole
See Also
SessionImpl, StatelessSessionImpl

Field Summary

Modifier and TypeField and Description
private final boolean
private CacheMode
private transient CacheTransactionSynchronization
protected boolean
private final PhysicalConnectionHandlingMode
private boolean
private transient TransactionImplementor
private transient EntityNameResolver
private transient ExceptionConverter
private transient SessionFactoryImpl
factory

Deprecated as a consequence of SessionFactoryImpl being deprecated.
protected transient FastSessionServices
private FlushMode
private final Interceptor
private final boolean
private Integer
private transient JdbcConnectionAccess
private transient JdbcCoordinator
private transient JdbcSessionContext
private final TimeZone
private static final EntityManagerMessageLogger
private boolean
private transient SessionEventListenerManager
private UUID
private Object
private final Object
private transient TransactionCoordinator
protected boolean

Constructor Summary

AccessConstructor and Description
public
AbstractSharedSessionContract(SessionFactoryImpl factory, SessionCreationOptions options)

Deprecated as a consequence of SessionFactoryImpl being deprecated.

Method Summary

Modifier and TypeMethod and Description
public Transaction
accessTransaction()

Implements org.hibernate.engine.spi.SharedSessionContractImplementor.accessTransaction.

Retrieves the current Transaction, or creates a new transaction if there is no transaction active.
protected <T> void
addResultType(Class<T> resultClass, NativeQueryImplementor<T> query)

protected void
public void
afterTransactionCompletion(boolean
Was the transaction successful?
successful
,
boolean
Is this a delayed after transaction completion call (aka after a timeout)?
delayed
)

Implements org.hibernate.resource.jdbc.spi.JdbcSessionOwner.afterTransactionCompletion.

An after-completion callback to the owner.
protected void
protected void
public void
public Transaction
beginTransaction()

Implements org.hibernate.SharedSessionContract.beginTransaction.

Begin a unit of work and return the associated Transaction object.
protected <Q> Q
protected <T> QueryImplementor<T>
buildNamedQuery(String queryName, Class<T> resultType)

protected static void
checkMutationQuery(String hqlString, SqmStatement<?> sqmStatement)

public void
checkOpen(boolean markForRollbackIfClosed)

Implements org.hibernate.engine.spi.SharedSessionContractImplementor.checkOpen.

Check whether the session is open, and if not:
  • if markForRollbackIfClosed = true, mark the current transaction, if any, for rollback only, and
  • throw an IllegalStateException. (JPA specifies this exception type.)
protected void
protected static <R> void
checkResultType(Class<R> expectedResultType, SqmSelectionQueryImpl<R> query)

protected static void
public void
checkTransactionNeededForUpdateOperation(String
the message to use for the TransactionRequiredException
exceptionMessage
)

Overrides default org.hibernate.engine.spi.SharedSessionContractImplementor.checkTransactionNeededForUpdateOperation.

Check if an active Transaction is available before performing an update operation against the database.
protected void
protected void
public void
close()

Implements org.hibernate.SharedSessionContract.close.

End the session by releasing the JDBC connection and cleaning up.
private <T> QueryImplementor<T>
createCriteriaQuery(SqmStatement<T> criteria, Class<T> resultType)

public <T> RootGraphImplementor<T>
createEntityGraph(Class<T>
the root entity class of the graph
rootType
)

Implements org.hibernate.SharedSessionContract.createEntityGraph.

Create a new mutable EntityGraph with only a root node.
public <T> RootGraph<T>
createEntityGraph(Class<T>
the root entity class of the graph
rootType
,
String
the name of the graph
graphName
)

Implements org.hibernate.SharedSessionContract.createEntityGraph.

Create a new mutable copy of the named EntityGraph, or return null if there is no graph with the given name.
public RootGraphImplementor<?>
createEntityGraph(String
the name of the graph
graphName
)

Implements org.hibernate.SharedSessionContract.createEntityGraph.

Create a new mutable copy of the named EntityGraph, or return null if there is no graph with the given name.
private JdbcCoordinatorImpl
private JdbcSessionContextImpl
public MutationQuery
public MutationQuery
public MutationQuery
public MutationQuery
createMutationQuery(JpaCriteriaInsertSelect<T> insertSelect)

Implements org.hibernate.query.QueryProducer.createMutationQuery.

Create a MutationQuery from the given insert-select criteria tree
public MutationQuery
private <R> SelectionQuery<R>
public QueryImplementor<R>
createNamedQuery(String
the name of a predefined named query
name
)

Implements org.hibernate.query.QueryProducer.createNamedQuery, org.hibernate.query.spi.QueryProducerImplementor.createNamedQuery.

Create a typed Query instance for the given named query.
public <R> QueryImplementor<R>
createNamedQuery(String
the name of a query defined in metadata
name
,
Class<R>
the type of the query result
resultClass
)

Implements org.hibernate.query.QueryProducer.createNamedQuery, org.hibernate.query.spi.QueryProducerImplementor.createNamedQuery.

Create a typed Query instance for the given named query.
public SelectionQuery<?>
public <R> SelectionQuery<R>
createNamedSelectionQuery(String queryName, Class<R> expectedResultType)

Implements org.hibernate.query.QueryProducer.createNamedSelectionQuery.

Create a SelectionQuery instance for the named jakarta.persistence.NamedQuery with the given result type.
private <R> SqmSelectionQuery<R>
public ProcedureCall
createNamedStoredProcedureQuery(String
The name given to the template
name
)

Implements org.hibernate.SharedSessionContract.createNamedStoredProcedureQuery.

Obtain a ProcedureCall based on a named template
public MutationQuery
public NativeQueryImpl<R>
createNativeQuery(String
a native SQL query string
sqlString
)

Implements org.hibernate.query.QueryProducer.createNativeQuery, org.hibernate.query.spi.QueryProducerImplementor.createNativeQuery.

Create a NativeQuery instance for the given native SQL query.
public NativeQueryImplementor<R>
createNativeQuery(String
The native (SQL) query string
sqlString
,
String
The explicit result mapping name
resultSetMappingName
)

Implements org.hibernate.query.QueryProducer.createNativeQuery, org.hibernate.query.spi.QueryProducerImplementor.createNativeQuery.

Create a NativeQuery instance for the given native SQL query using an explicit mapping to the specified Java type.
public NativeQueryImplementor<R>
createNativeQuery(String
The native (SQL) query string
sqlString
,
Class<T>
The Java type to map results to
resultClass
)

Implements org.hibernate.query.QueryProducer.createNativeQuery, org.hibernate.query.spi.QueryProducerImplementor.createNativeQuery.

Create a NativeQuery instance for the given native SQL query using an implicit mapping to the specified Java type.
public <T> NativeQueryImplementor<T>
createNativeQuery(String
Native (SQL) query string
sqlString
,
Class<T>
The Java entity class to map results to
resultClass
,
String
The table alias for columns in the result set
tableAlias
)

Implements org.hibernate.query.QueryProducer.createNativeQuery, org.hibernate.query.spi.QueryProducerImplementor.createNativeQuery.

Create a NativeQuery instance for the given native SQL query using an implicit mapping to the specified Java entity type.
public <T> NativeQueryImplementor<T>
createNativeQuery(String
The native (SQL) query string
sqlString
,
String
The explicit result mapping name
resultSetMappingName
,
Class<T> resultClass)

Implements org.hibernate.query.QueryProducer.createNativeQuery, org.hibernate.query.spi.QueryProducerImplementor.createNativeQuery.

Create a NativeQuery instance for the given native SQL query using an explicit mapping to the specified Java type.
protected <T> NativeQueryImplementor<T>
protected NativeQueryImplementor<?>
public QueryImplementor<R>
createQuery(String
The HQL query
queryString
)

Implements org.hibernate.query.QueryProducer.createQuery, org.hibernate.query.spi.QueryProducerImplementor.createQuery.

Create a Query instance for the given HQL query, or HQL insert, update, or delete statement.
public <T> QueryImplementor<T>
createQuery(String
The HQL query
queryString
,
Class<T>
The type of the query result
expectedResultType
)

Implements org.hibernate.query.QueryProducer.createQuery, org.hibernate.query.spi.QueryProducerImplementor.createQuery.

Create a typed Query instance for the given HQL query string and given query result type.
public <T> QueryImplementor<T>
public QueryImplementor<R>
public QueryImplementor<R>
public SelectionQuery<?>
createSelectionQuery(String hqlString)

Implements org.hibernate.query.QueryProducer.createSelectionQuery.

Create a SelectionQuery reference for the given HQL select statement.
private <R> SelectionQuery<R>
createSelectionQuery(String hql, Class<R> resultType, HqlInterpretation interpretation)

public <R> SelectionQuery<R>
createSelectionQuery(String
The HQL query as a string
hqlString
,
Class<R>
The Class object representing the query result type
expectedResultType
)

Implements org.hibernate.query.QueryProducer.createSelectionQuery.

Create a SelectionQuery instance for the given HQL query string and given query result type.
public <R> SelectionQuery<R>
private SessionEventListenerManager
protected <T> SqmQueryImplementor<T>
protected SqmQueryImplementor<?>
public ProcedureCall
createStoredProcedureCall(String
The name of the procedure.
procedureName
)

Implements org.hibernate.SharedSessionContract.createStoredProcedureCall.

Create a ProcedureCall to a stored procedure.
public ProcedureCall
createStoredProcedureCall(String
The name of the procedure.
procedureName
,
Class<?>...
The entity(s) to map the result on to.
resultClasses
)

Implements org.hibernate.SharedSessionContract.createStoredProcedureCall.

Create a ProcedureCall to a stored procedure with the given result set entity mappings.
public ProcedureCall
createStoredProcedureCall(String
The name of the procedure.
procedureName
,
String...
The explicit result set mapping(s) to use for mapping the results
resultSetMappings
)

Implements org.hibernate.SharedSessionContract.createStoredProcedureCall.

Create a ProcedureCall to a stored procedure with the given result set entity mappings.
public ProcedureCall
createStoredProcedureQuery(String
The name of the procedure.
procedureName
)

Implements org.hibernate.SharedSessionContract.createStoredProcedureQuery.

Create a ProcedureCall to a stored procedure.
public ProcedureCall
createStoredProcedureQuery(String
The name of the procedure.
procedureName
,
Class<?>...
The entity(s) to map the result on to.
resultClasses
)

Implements org.hibernate.SharedSessionContract.createStoredProcedureQuery.

Create a ProcedureCall to a stored procedure with the given result set entity mappings.
public ProcedureCall
createStoredProcedureQuery(String
The name of the procedure.
procedureName
,
String...
The explicit result set mapping(s) to use for mapping the results
resultSetMappings
)

Implements org.hibernate.SharedSessionContract.createStoredProcedureQuery.

Create a ProcedureCall to a stored procedure with the given result set entity mappings.
protected void
public <T> T
doReturningWork(final ReturningWork<T>
The work to be performed.
work
)

Overrides default org.hibernate.SharedSessionContract.doReturningWork.

Perform work using the java.sql.Connection underlying by this session, and return a result.
public void
doWork(final Work
The work to be performed.
work
)

Overrides default org.hibernate.SharedSessionContract.doWork.

Perform work using the java.sql.Connection underlying by this session.
private <T> T
public <T> T
execute(final LobCreationContext.Callback<T>
The callback to execute .
callback
)

Implements org.hibernate.engine.jdbc.LobCreationContext.execute.

Execute the given callback, making sure it has access to a viable JDBC Connection.
public EntityKey
generateEntityKey(Object
The entity id
id
,
EntityPersister
The entity persister
persister
)

Implements org.hibernate.engine.spi.SharedSessionContractImplementor.generateEntityKey.

Instantiate an EntityKey with the given id and for the entity represented by the given EntityPersister.
public CacheMode
public CacheTransactionSynchronization
public Integer
getConfiguredJdbcBatchSize()

Overrides default org.hibernate.engine.spi.SharedSessionContractImplementor.getConfiguredJdbcBatchSize.

Override the implementation provided on SharedSessionContractImplementor which is not very efficient: this method is hot in Hibernate Reactive, and could be hot in some ORM contexts as well.
public HibernateCriteriaBuilder
protected TransactionImplementor
public RootGraphImplementor<?>
getEntityGraph(String
the name of the graph
graphName
)

Implements org.hibernate.SharedSessionContract.getEntityGraph.

Retrieve the named EntityGraph as an immutable graph, or return null if there is no graph with the given name.
public <T> List<EntityGraph<? super T>>
getEntityGraphs(Class<T> entityClass)

Implements org.hibernate.SharedSessionContract.getEntityGraphs.

Retrieve all named EntityGraphs with the given type.
public EntityNameResolver
public SessionEventListenerManager
public EventManager
public ExceptionConverter
public SessionFactoryImplementor
getFactory()

Implements org.hibernate.engine.spi.SharedSessionContractImplementor.getFactory.

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
Obtain the factory which created this session.
public FlushModeType
public FlushMode
public Interceptor
public Integer
public JdbcConnectionAccess
public JdbcCoordinator
public JdbcServices
getJdbcServices()

Implements org.hibernate.engine.spi.SharedSessionContractImplementor.getJdbcServices.

Obtain the JdbcServices for the factory which created this session.
public JdbcSessionContext
public TimeZone
getJdbcTimeZone()

Implements org.hibernate.type.descriptor.WrapperOptions.getJdbcTimeZone.

The JDBC TimeZone used when writing a value of type java.sql.Time or java.sql.Timestamp to a JDBC java.sql.PreparedStatement, or when reading from a JDBC java.sql.ResultSet.
public LobCreator
public NativeQueryImplementor<R>
public NativeQueryImplementor<R>
getNamedNativeQuery(String
The name of the predefined query
queryName
,
String resultSetMapping)

Implements org.hibernate.query.QueryProducer.getNamedNativeQuery, org.hibernate.query.spi.QueryProducerImplementor.getNamedNativeQuery.

Get a NativeQuery instance for a named native SQL query
public ProcedureCall
getNamedProcedureCall(String
The name given to the template
name
)

Implements org.hibernate.SharedSessionContract.getNamedProcedureCall.

Obtain a ProcedureCall based on a named template
public QueryImplementor<R>
getNamedQuery(String
the name of a predefined named query
queryName
)

Implements org.hibernate.query.QueryProducer.getNamedQuery, org.hibernate.query.spi.QueryProducerImplementor.getNamedQuery.

Create a Query instance for the named query.
public boolean
private NamedNativeQueryMemento
public int
protected NamedResultSetMappingMemento
getResultSetMappingMemento(String resultSetMappingName)

public UUID
public Object
getSessionToken()

Overrides default org.hibernate.engine.spi.SharedSessionContractImplementor.getSessionToken.

Obtain a "token" which uniquely identifies this session.
private NamedSqmQueryMemento
private Object
getTenantId(SessionFactoryImpl factory, SessionCreationOptions options)

Deprecated as a consequence of SessionFactoryImpl being deprecated.
public String
getTenantIdentifier()

Implements org.hibernate.SharedSessionContract.getTenantIdentifier.

Obtain the tenant identifier associated with this session.
public Object
getTenantIdentifierValue()

Implements org.hibernate.SharedSessionContract.getTenantIdentifierValue.

Obtain the tenant identifier associated with this session.
public Transaction
getTransaction()

Implements org.hibernate.SharedSessionContract.getTransaction.

Get the Transaction instance associated with this session.
public TransactionCoordinator
getTransactionCoordinator()

Implements org.hibernate.resource.jdbc.spi.JdbcSessionOwner.getTransactionCoordinator.

Obtain the builder for TransactionCoordinator instances
private Interceptor
interpret(Interceptor interceptor)

private StatementInspector
interpret(StatementInspector statementInspector)

private <R> SelectionQuery<R>
protected <R> HqlInterpretation
interpretHql(String hql, Class<R> resultType)

public boolean
isClosed()

Implements org.hibernate.engine.spi.SharedSessionContractImplementor.isClosed.

Determines whether the session is closed.
public boolean
isConnected()

Implements org.hibernate.SharedSessionContract.isConnected.

Check if the session is currently connected.
public boolean
public boolean
isJoinedToTransaction()

Implements org.hibernate.SharedSessionContract.isJoinedToTransaction.

Check if the session is joined to the current transaction.
public boolean
isOpen()

Implements org.hibernate.SharedSessionContract.isOpen.

Check if the session is still open.
public boolean
isOpenOrWaitingForAutoClose()

Overrides default org.hibernate.engine.spi.SharedSessionContractImplementor.isOpenOrWaitingForAutoClose.

Determines whether the session is open or is waiting for auto-close.
private static boolean
public boolean
isTransactionInProgress()

Implements org.hibernate.engine.spi.SharedSessionContractImplementor.isTransactionInProgress.

Does this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?
public void
joinTransaction()

Implements org.hibernate.SharedSessionContract.joinTransaction.

Join the currently-active JTA transaction.
protected abstract Object
load(String entityName, Object identifier)

private void
public void
markForRollbackOnly()

Implements org.hibernate.engine.spi.SharedSessionContractImplementor.markForRollbackOnly.

Marks current transaction, if any, for rollback only.
private RuntimeException
protected void
public void
protected void
private void
protected void
public void
protected void
public void
public void
public void
setJdbcBatchSize(Integer
the new session-level JDBC batch size
jdbcBatchSize
)

Implements org.hibernate.SharedSessionContract.setJdbcBatchSize.

Set the session-level JDBC batch size.
public void
protected final void
setUpMultitenancy(SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
public boolean
shouldAutoJoinTransaction()

Implements org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder.Options.shouldAutoJoinTransaction.

Indicates whether an active transaction should be automatically joined.
protected boolean
shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared)

public void
startTransactionBoundary()

Implements org.hibernate.resource.jdbc.spi.JdbcSessionOwner.startTransactionBoundary.

Callback indicating recognition of entering into a transactional context whether that is explicitly via the Hibernate org.hibernate.Transaction API or via registration of Hibernate's JTA Synchronization impl with a JTA Transaction
public boolean
useStreamForLobBinding()

Implements org.hibernate.type.descriptor.WrapperOptions.useStreamForLobBinding.

Determines whether streams should be used for binding LOB values.
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait