Class AbstractSharedSessionContract
- java.lang.Object
-
- org.hibernate.internal.AbstractSharedSessionContract
-
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
,LobCreationContext
,SharedSessionContractImplementor
,QueryProducer
,QueryProducerImplementor
,JdbcSessionOwner
,TransactionCoordinatorBuilder.Options
,SharedSessionContract
,JavaType.CoercionContext
,WrapperOptions
- Direct Known Subclasses:
SessionImpl
,StatelessSessionImpl
public abstract class AbstractSharedSessionContract extends Object implements SharedSessionContractImplementor
Base class for implementations ofSharedSessionContract
andSharedSessionContractImplementor
. Intended for concrete implementations ofSession
andStatelessSession
.NOTE: This implementation defines access to a number of instance state values in a manner that is not exactly concurrent-access safe. However, a Session/EntityManager is never intended to be used concurrently; therefore the condition is not expected and so a more synchronized/concurrency-safe is not defined to be as negligent (performance-wise) as possible. Some of these methods include:
getEventListenerManager()
getJdbcConnectionAccess()
getJdbcServices()
getTransaction()
(and therefore related methods such asbeginTransaction()
, etc)
- See Also:
SessionImpl
,StatelessSessionImpl
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hibernate.engine.jdbc.LobCreationContext
LobCreationContext.Callback<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
closed
protected FastSessionServices
fastSessionServices
protected boolean
waitingForAutoClose
-
Constructor Summary
Constructors Constructor Description AbstractSharedSessionContract(SessionFactoryImpl factory, SessionCreationOptions options)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Transaction
accessTransaction()
Provides access to the underlying transaction or creates a new transaction if one does not already exist or is active.protected void
addSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)
void
afterTransactionCompletion(boolean successful, boolean delayed)
An after-completion callback to the owner.protected void
applyQuerySettingsAndHints(Query<?> query)
protected void
applyQuerySettingsAndHints(SelectionQuery<?> query)
void
beforeTransactionCompletion()
A before-completion callback to the owner.Transaction
beginTransaction()
Begin a unit of work and return the associatedTransaction
object.protected <T> QueryImplementor<T>
buildNamedQuery(String queryName, Class<T> resultType)
protected QueryImplementor
buildNamedQuery(String queryName, Function<NamedSqmQueryMemento,SqmQueryImplementor> namedSqmHandler, Function<NamedNativeQueryMemento,NativeQueryImplementor> namedNativeHandler)
void
checkOpen(boolean markForRollbackIfClosed)
Performs a check whether the Session is open, and if not: ifmarkForRollbackIfClosed
is true, marks current transaction (if one) for rollback only throws an IllegalStateException (JPA defines the exception type)protected void
checkOpenOrWaitingForAutoClose()
void
checkTransactionNeededForUpdateOperation(String exceptionMessage)
Check if an active Transaction is necessary for the update operation to be executed.protected void
checkTransactionSynchStatus()
protected void
cleanupOnClose()
void
close()
End the session by releasing the JDBC connection and cleaning up.MutationQuery
createMutationQuery(jakarta.persistence.criteria.CriteriaDelete deleteQuery)
Create aMutationQuery
from the given delete criteria treeMutationQuery
createMutationQuery(jakarta.persistence.criteria.CriteriaUpdate updateQuery)
Create aMutationQuery
from the given update criteria treeMutationQuery
createMutationQuery(String hqlString)
Create a MutationQuery reference for the given HQL insert, update, or delete statement.MutationQuery
createMutationQuery(JpaCriteriaInsertSelect insertSelect)
Create aMutationQuery
from the given insert-select criteria treeMutationQuery
createNamedMutationQuery(String queryName)
Create aMutationQuery
instance for the given named insert, update, or delete HQL query.QueryImplementor
createNamedQuery(String name)
Create a typedQuery
instance for the given named query.<R> QueryImplementor<R>
createNamedQuery(String name, Class<R> resultClass)
Create a typedQuery
instance for the given named query.SelectionQuery<?>
createNamedSelectionQuery(String queryName)
Create aSelectionQuery
instance for the namedNamedQuery
<R> SelectionQuery<R>
createNamedSelectionQuery(String queryName, Class<R> expectedResultType)
Create aSelectionQuery
instance for the namedNamedQuery
with the expected result-typeProcedureCall
createNamedStoredProcedureQuery(String name)
Obtain aProcedureCall
based on a named templateMutationQuery
createNativeMutationQuery(String sqlString)
Create aNativeQuery
instance for the given native (SQL) statementNativeQueryImpl
createNativeQuery(String sqlString)
Create aNativeQuery
instance for the given native (SQL) queryNativeQueryImplementor
createNativeQuery(String sqlString, Class resultClass)
Create aNativeQuery
instance for the given native (SQL) query using implicit mapping to the specified Java type.<T> NativeQueryImplementor<T>
createNativeQuery(String sqlString, Class<T> resultClass, String tableAlias)
Create aNativeQuery
instance for the given native (SQL) query using implicit mapping to the specified Java type.NativeQueryImplementor
createNativeQuery(String sqlString, String resultSetMappingName)
Create aNativeQuery
instance for the given native (SQL) query using implicit mapping to the specified Java type.<T> NativeQueryImplementor<T>
createNativeQuery(String sqlString, String resultSetMappingName, Class<T> resultClass)
Create aNativeQuery
instance for the given native (SQL) query using implicit mapping to the specified Java type.QueryImplementor
createQuery(jakarta.persistence.criteria.CriteriaDelete criteriaDelete)
Create aMutationQuery
for the given JPACriteriaDelete
<T> QueryImplementor<T>
createQuery(jakarta.persistence.criteria.CriteriaQuery<T> criteriaQuery)
Create aQuery
for the given JPACriteriaQuery
QueryImplementor
createQuery(jakarta.persistence.criteria.CriteriaUpdate criteriaUpdate)
Create aMutationQuery
for the given JPACriteriaUpdate
QueryImplementor
createQuery(String queryString)
Create aQuery
instance for the given HQL query, or HQL insert, update, or delete statement.<T> QueryImplementor<T>
createQuery(String queryString, Class<T> expectedResultType)
Create a typedQuery
instance for the given HQL query string.<R> SelectionQuery<R>
createSelectionQuery(jakarta.persistence.criteria.CriteriaQuery<R> criteria)
Create aSelectionQuery
reference for the given Criteria.SelectionQuery<?>
createSelectionQuery(String hqlString)
Create aSelectionQuery
reference for the given HQL.<R> SelectionQuery<R>
createSelectionQuery(String hqlString, Class<R> expectedResultType)
Create aSelectionQuery
reference for the given HQL.ProcedureCall
createStoredProcedureCall(String procedureName)
Create aProcedureCall
to a stored procedure.ProcedureCall
createStoredProcedureCall(String procedureName, Class<?>... resultClasses)
Create aProcedureCall
to a stored procedure with the given result set entity mappings.ProcedureCall
createStoredProcedureCall(String procedureName, String... resultSetMappings)
Create aProcedureCall
to a stored procedure with the given result set entity mappings.ProcedureCall
createStoredProcedureQuery(String procedureName)
Create aProcedureCall
to a stored procedure.ProcedureCall
createStoredProcedureQuery(String procedureName, Class<?>... resultClasses)
Create aProcedureCall
to a stored procedure with the given result set entity mappings.ProcedureCall
createStoredProcedureQuery(String procedureName, String... resultSetMappings)
Create aProcedureCall
to a stored procedure with the given result set entity mappings.protected void
delayedAfterCompletion()
<T> T
doReturningWork(ReturningWork<T> work)
Perform work using theConnection
underlying by this session, and return a result.void
doWork(Work work)
Perform work using theConnection
underlying by this session.<T> T
execute(LobCreationContext.Callback<T> callback)
Execute the given callback, making sure it has access to a viable JDBCConnection
.EntityKey
generateEntityKey(Object id, EntityPersister persister)
Hide the changing requirements of entity key creationCacheMode
getCacheMode()
CacheTransactionSynchronization
getCacheTransactionSynchronization()
The current CacheTransactionContext associated with the Session.Integer
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.HibernateCriteriaBuilder
getCriteriaBuilder()
Return an instance ofCriteriaBuilder
.protected TransactionImplementor
getCurrentTransaction()
EntityNameResolver
getEntityNameResolver()
SessionEventListenerManager
getEventListenerManager()
ExceptionConverter
getExceptionConverter()
The converter associated to a Session might be lazily initialized: only invoke this getter when there is actual need to use it.SessionFactoryImplementor
getFactory()
Get the creatingSessionFactoryImplementor
jakarta.persistence.FlushModeType
getFlushMode()
Get the flush mode for this session.FlushMode
getHibernateFlushMode()
Get the current flush mode for this session.Interceptor
getInterceptor()
Retrieves the interceptor currently in use by this event source.Integer
getJdbcBatchSize()
Get the session-level JDBC batch size for the current session.JdbcConnectionAccess
getJdbcConnectionAccess()
JdbcCoordinator
getJdbcCoordinator()
JdbcServices
getJdbcServices()
JdbcSessionContext
getJdbcSessionContext()
TimeZone
getJdbcTimeZone()
The JDBCTimeZone
used when writing a value of typeTime
orTimestamp
to a JDBCPreparedStatement
, or when reading from a JDBCResultSet
.LobCreator
getLobCreator()
Obtain access to theLobCreator
.NativeQueryImplementor
getNamedNativeQuery(String queryName)
Get aNativeQuery
instance for a named native SQL queryNativeQueryImplementor
getNamedNativeQuery(String queryName, String resultSetMapping)
Get aNativeQuery
instance for a named native SQL queryProcedureCall
getNamedProcedureCall(String name)
Obtain aProcedureCall
based on a named templateQueryImplementor
getNamedQuery(String queryName)
Create aQuery
instance for the named query.int
getPreferredSqlTypeCodeForBoolean()
The JDBCtype code
used to bind a null boolean value.UUID
getSessionIdentifier()
A UUID associated with each Session.Object
getSessionToken()
A "token" that is unique to this Session.String
getTenantIdentifier()
The multi-tenancy tenant identifier, if one.Transaction
getTransaction()
Get theTransaction
instance associated with this session.TransactionCoordinator
getTransactionCoordinator()
Obtain the builder for TransactionCoordinator instancesboolean
isClosed()
Checks whether the session is closed.boolean
isConnected()
Check if the session is currently connected.boolean
isCriteriaCopyTreeEnabled()
boolean
isOpen()
Check if the session is still open.boolean
isOpenOrWaitingForAutoClose()
Checks whether the session is open or is waiting for auto-closeboolean
isTransactionInProgress()
Does thisSession
have an active Hibernate transaction or is there a JTA transaction in progress?protected abstract Object
load(String entityName, Object identifier)
void
markForRollbackOnly()
Marks current transaction (if one) for rollback onlyprotected void
prepareForAutoClose()
void
prepareForQueryExecution(boolean requiresTxn)
Prepare for the execution of aQuery
orProcedureCall
protected void
pulseTransactionCoordinator()
protected void
removeSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)
void
setCacheMode(CacheMode cacheMode)
protected void
setClosed()
void
setCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled)
void
setHibernateFlushMode(FlushMode flushMode)
Set the flush mode for this session.void
setJdbcBatchSize(Integer jdbcBatchSize)
Set the session-level JDBC batch size.boolean
shouldAutoJoinTransaction()
Indicates whether an active transaction should be automatically joined.protected boolean
shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared)
void
startTransactionBoundary()
Callback indicating recognition of entering into a transactional context whether that is explicitly via the HibernateTransaction
API or via registration of Hibernate's JTA Synchronization impl with a JTA Transactionboolean
useStreamForLobBinding()
Determines whether streams should be used for binding LOB values.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.resource.jdbc.spi.JdbcSessionOwner
afterTransactionBegin, flushBeforeTransactionCompletion
-
Methods inherited from interface org.hibernate.engine.spi.SharedSessionContractImplementor
afterOperation, afterScrollOperation, asEventSource, asSessionImplementor, asStatelessSession, autoFlushIfRequired, bestGuessEntityName, checkOpen, flush, getContextEntityIdentifier, getEntityPersister, getEntityUsingInterceptor, getLoadQueryInfluencers, getPersistenceContext, getPersistenceContextInternal, getSession, getSessionFactory, getTypeConfiguration, guessEntityName, immediateLoad, initializeCollection, instantiate, instantiate, internalLoad, isAutoCloseSessionEnabled, isDefaultReadOnly, isEnforcingFetchGraph, isEventSource, isSessionImplementor, isStatelessSession, setAutoClear, setEnforcingFetchGraph, shouldAutoClose
-
-
-
-
Field Detail
-
fastSessionServices
protected transient FastSessionServices fastSessionServices
-
closed
protected boolean closed
-
waitingForAutoClose
protected boolean waitingForAutoClose
-
-
Constructor Detail
-
AbstractSharedSessionContract
public AbstractSharedSessionContract(SessionFactoryImpl factory, SessionCreationOptions options)
-
-
Method Detail
-
getConfiguredJdbcBatchSize
public Integer 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.- Specified by:
getConfiguredJdbcBatchSize
in interfaceSharedSessionContractImplementor
- Returns:
- Session-level or SessionFactory-level JDBC batch size.
- See Also:
SessionFactoryOptions.getJdbcBatchSize()
,SessionFactoryBuilder.applyJdbcBatchSize(int)
-
addSharedSessionTransactionObserver
protected void addSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)
-
removeSharedSessionTransactionObserver
protected void removeSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)
-
prepareForAutoClose
protected void prepareForAutoClose()
-
shouldAutoJoinTransaction
public boolean shouldAutoJoinTransaction()
Description copied from interface:TransactionCoordinatorBuilder.Options
Indicates whether an active transaction should be automatically joined. Only relevant for JTA-based TransactionCoordinator instances.- Specified by:
shouldAutoJoinTransaction
in interfaceTransactionCoordinatorBuilder.Options
- Returns:
true
indicates the active transaction should be auto joined;false
indicates it should not (untilTransactionCoordinator.explicitJoin()
is called).
-
getFactory
public SessionFactoryImplementor getFactory()
Description copied from interface:SharedSessionContractImplementor
Get the creatingSessionFactoryImplementor
- Specified by:
getFactory
in interfaceQueryProducerImplementor
- Specified by:
getFactory
in interfaceSharedSessionContractImplementor
-
getInterceptor
public Interceptor getInterceptor()
Description copied from interface:SharedSessionContractImplementor
Retrieves the interceptor currently in use by this event source.- Specified by:
getInterceptor
in interfaceSharedSessionContractImplementor
- Returns:
- The interceptor.
-
getJdbcCoordinator
public JdbcCoordinator getJdbcCoordinator()
- Specified by:
getJdbcCoordinator
in interfaceSharedSessionContractImplementor
-
getTransactionCoordinator
public TransactionCoordinator getTransactionCoordinator()
Description copied from interface:JdbcSessionOwner
Obtain the builder for TransactionCoordinator instances- Specified by:
getTransactionCoordinator
in interfaceJdbcSessionOwner
- Returns:
- The TransactionCoordinatorBuilder
-
getJdbcSessionContext
public JdbcSessionContext getJdbcSessionContext()
- Specified by:
getJdbcSessionContext
in interfaceJdbcSessionOwner
-
getEntityNameResolver
public EntityNameResolver getEntityNameResolver()
-
getEventListenerManager
public SessionEventListenerManager getEventListenerManager()
- Specified by:
getEventListenerManager
in interfaceSharedSessionContractImplementor
-
getSessionIdentifier
public UUID getSessionIdentifier()
Description copied from interface:SharedSessionContractImplementor
A UUID associated with each Session. Useful mainly for logging.- Specified by:
getSessionIdentifier
in interfaceSharedSessionContractImplementor
- Returns:
- The UUID
-
getSessionToken
public Object getSessionToken()
Description copied from interface:SharedSessionContractImplementor
A "token" that is unique to this Session.- Specified by:
getSessionToken
in interfaceSharedSessionContractImplementor
- Returns:
- The token
-
getTenantIdentifier
public String getTenantIdentifier()
Description copied from interface:SharedSessionContractImplementor
The multi-tenancy tenant identifier, if one.- Specified by:
getTenantIdentifier
in interfaceSharedSessionContract
- Specified by:
getTenantIdentifier
in interfaceSharedSessionContractImplementor
- Returns:
- The tenant identifier; may be
null
-
isOpen
public boolean isOpen()
Description copied from interface:SharedSessionContract
Check if the session is still open.- Specified by:
isOpen
in interfaceSharedSessionContract
- Returns:
- boolean
-
isClosed
public boolean isClosed()
Description copied from interface:SharedSessionContractImplementor
Checks whether the session is closed. Provided separately fromSharedSessionContract.isOpen()
as this method does not attempt any JTA synchronization registration, whereasSharedSessionContract.isOpen()
does; which makes this one nicer to use for most internal purposes.- Specified by:
isClosed
in interfaceSharedSessionContractImplementor
- Returns:
true
if the session is closed;false
otherwise.
-
close
public void close()
Description copied from interface:SharedSessionContract
End the session by releasing the JDBC connection and cleaning up.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceSharedSessionContract
-
setClosed
protected void setClosed()
-
shouldCloseJdbcCoordinatorOnClose
protected boolean shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared)
-
cleanupOnClose
protected void cleanupOnClose()
-
isOpenOrWaitingForAutoClose
public boolean isOpenOrWaitingForAutoClose()
Description copied from interface:SharedSessionContractImplementor
Checks whether the session is open or is waiting for auto-close- Specified by:
isOpenOrWaitingForAutoClose
in interfaceSharedSessionContractImplementor
- Returns:
true
if the session is closed or if it's waiting for auto-close;false
otherwise.
-
checkOpen
public void checkOpen(boolean markForRollbackIfClosed)
Description copied from interface:SharedSessionContractImplementor
Performs a check whether the Session is open, and if not:- if
markForRollbackIfClosed
is true, marks current transaction (if one) for rollback only - throws an IllegalStateException (JPA defines the exception type)
- Specified by:
checkOpen
in interfaceSharedSessionContractImplementor
- if
-
prepareForQueryExecution
public void prepareForQueryExecution(boolean requiresTxn)
Description copied from interface:SharedSessionContractImplementor
Prepare for the execution of aQuery
orProcedureCall
- Specified by:
prepareForQueryExecution
in interfaceSharedSessionContractImplementor
-
checkOpenOrWaitingForAutoClose
protected void checkOpenOrWaitingForAutoClose()
-
markForRollbackOnly
public void markForRollbackOnly()
Description copied from interface:SharedSessionContractImplementor
Marks current transaction (if one) for rollback only- Specified by:
markForRollbackOnly
in interfaceSharedSessionContractImplementor
-
isTransactionInProgress
public boolean isTransactionInProgress()
Description copied from interface:SharedSessionContractImplementor
Does thisSession
have an active Hibernate transaction or is there a JTA transaction in progress?- Specified by:
isTransactionInProgress
in interfaceSharedSessionContractImplementor
-
checkTransactionNeededForUpdateOperation
public void checkTransactionNeededForUpdateOperation(String exceptionMessage)
Description copied from interface:SharedSessionContractImplementor
Check if an active Transaction is necessary for the update operation to be executed. If an active Transaction is necessary but it is not then a TransactionRequiredException is raised.- Specified by:
checkTransactionNeededForUpdateOperation
in interfaceSharedSessionContractImplementor
- Parameters:
exceptionMessage
- the message to use for the TransactionRequiredException
-
getTransaction
public Transaction getTransaction() throws HibernateException
Description copied from interface:SharedSessionContract
Get theTransaction
instance associated with this session.- Specified by:
getTransaction
in interfaceSharedSessionContract
- Returns:
- a Transaction instance
- Throws:
HibernateException
-
accessTransaction
public Transaction accessTransaction()
Description copied from interface:SharedSessionContractImplementor
Provides access to the underlying transaction or creates a new transaction if one does not already exist or is active. This is primarily for internal or integrator use.- Specified by:
accessTransaction
in interfaceSharedSessionContractImplementor
- Returns:
- the transaction
-
startTransactionBoundary
public void startTransactionBoundary()
Description copied from interface:JdbcSessionOwner
Callback indicating recognition of entering into a transactional context whether that is explicitly via the HibernateTransaction
API or via registration of Hibernate's JTA Synchronization impl with a JTA Transaction- Specified by:
startTransactionBoundary
in interfaceJdbcSessionOwner
-
beforeTransactionCompletion
public void beforeTransactionCompletion()
Description copied from interface:JdbcSessionOwner
A before-completion callback to the owner.- Specified by:
beforeTransactionCompletion
in interfaceJdbcSessionOwner
-
afterTransactionCompletion
public void afterTransactionCompletion(boolean successful, boolean delayed)
Description copied from interface:JdbcSessionOwner
An after-completion callback to the owner.- Specified by:
afterTransactionCompletion
in interfaceJdbcSessionOwner
- Parameters:
successful
- Was the transaction successful?delayed
- Is this a delayed after transaction completion call (aka after a timeout)?
-
getCacheTransactionSynchronization
public CacheTransactionSynchronization getCacheTransactionSynchronization()
Description copied from interface:SharedSessionContractImplementor
The current CacheTransactionContext associated with the Session. This may returnnull
when the Session is not currently part of a transaction.- Specified by:
getCacheTransactionSynchronization
in interfaceSharedSessionContractImplementor
-
beginTransaction
public Transaction beginTransaction()
Description copied from interface:SharedSessionContract
Begin a unit of work and return the associatedTransaction
object. If a new underlying transaction is required, begin the transaction. Otherwise, continue the new work in the context of the existing underlying transaction.- Specified by:
beginTransaction
in interfaceSharedSessionContract
- Returns:
- a
Transaction
instance - See Also:
SharedSessionContract.getTransaction()
-
checkTransactionSynchStatus
protected void checkTransactionSynchStatus()
-
pulseTransactionCoordinator
protected void pulseTransactionCoordinator()
-
delayedAfterCompletion
protected void delayedAfterCompletion()
-
getCurrentTransaction
protected TransactionImplementor getCurrentTransaction()
-
isConnected
public boolean isConnected()
Description copied from interface:SharedSessionContract
Check if the session is currently connected.- Specified by:
isConnected
in interfaceSharedSessionContract
- Returns:
- boolean
-
getJdbcConnectionAccess
public JdbcConnectionAccess getJdbcConnectionAccess()
- Specified by:
getJdbcConnectionAccess
in interfaceJdbcSessionOwner
-
generateEntityKey
public EntityKey generateEntityKey(Object id, EntityPersister persister)
Description copied from interface:SharedSessionContractImplementor
Hide the changing requirements of entity key creation- Specified by:
generateEntityKey
in interfaceSharedSessionContractImplementor
- Parameters:
id
- The entity idpersister
- The entity persister- Returns:
- The entity key
-
useStreamForLobBinding
public boolean useStreamForLobBinding()
Description copied from interface:WrapperOptions
Determines whether streams should be used for binding LOB values.- Specified by:
useStreamForLobBinding
in interfaceWrapperOptions
- Returns:
true
/false
- See Also:
Dialect.useInputStreamToInsertBlob()
-
getPreferredSqlTypeCodeForBoolean
public int getPreferredSqlTypeCodeForBoolean()
Description copied from interface:WrapperOptions
The JDBCtype code
used to bind a null boolean value.- Specified by:
getPreferredSqlTypeCodeForBoolean
in interfaceWrapperOptions
- See Also:
AvailableSettings.PREFERRED_BOOLEAN_JDBC_TYPE
,Dialect.getPreferredSqlTypeCodeForBoolean()
-
getLobCreator
public LobCreator getLobCreator()
Description copied from interface:WrapperOptions
Obtain access to theLobCreator
.- Specified by:
getLobCreator
in interfaceWrapperOptions
- Returns:
- The LOB creator
- See Also:
AvailableSettings.NON_CONTEXTUAL_LOB_CREATION
,Dialect.getDefaultNonContextualLobCreation()
-
execute
public <T> T execute(LobCreationContext.Callback<T> callback)
Description copied from interface:LobCreationContext
Execute the given callback, making sure it has access to a viable JDBCConnection
.- Specified by:
execute
in interfaceLobCreationContext
- Type Parameters:
T
- The Java type of the type of LOB being created. One ofBlob
,Clob
,NClob
- Parameters:
callback
- The callback to execute .- Returns:
- The LOB created by the callback.
-
getJdbcTimeZone
public TimeZone getJdbcTimeZone()
Description copied from interface:WrapperOptions
The JDBCTimeZone
used when writing a value of typeTime
orTimestamp
to a JDBCPreparedStatement
, or when reading from a JDBCResultSet
.- When
getJdbcTimeZone()
is null, the methodPreparedStatement.setTimestamp(int, java.sql.Timestamp)
is called to write a timestamp, andResultSet.getTimestamp(int)
is called to read a timestamp. - But when not null, the method
PreparedStatement.setTimestamp(int, java.sql.Timestamp, java.util.Calendar)
is called to write a timestamp, andResultSet.getTimestamp(int, java.util.Calendar)
is called to read a timestamp.
TimeZone
can differ from the default JVM TimeZone given byTimeZone.getDefault()
.- Specified by:
getJdbcTimeZone
in interfaceWrapperOptions
- Returns:
- the JDBC
TimeZone
, or null if no JDBC timezone was explicitly set - See Also:
AvailableSettings.JDBC_TIME_ZONE
- When
-
getJdbcServices
public JdbcServices getJdbcServices()
- Specified by:
getJdbcServices
in interfaceSharedSessionContractImplementor
-
getFlushMode
public jakarta.persistence.FlushModeType getFlushMode()
Description copied from interface:SharedSessionContractImplementor
Get the flush mode for this session.For users of the Hibernate native APIs, we've had to rename this method as defined by Hibernate historically because the JPA contract defines a method of the same name, but returning the JPA
FlushModeType
rather than Hibernate'sFlushMode
. For the former behavior, useSharedSessionContractImplementor.getHibernateFlushMode()
instead.- Specified by:
getFlushMode
in interfaceSharedSessionContractImplementor
- Returns:
- The FlushModeType in effect for this Session.
-
setHibernateFlushMode
public void setHibernateFlushMode(FlushMode flushMode)
Description copied from interface:SharedSessionContractImplementor
Set the flush mode for this session.The flush mode determines the points at which the session is flushed. Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.
For a logically "read only" session, it is reasonable to set the session's flush mode to
FlushMode.MANUAL
at the start of the session (in order to achieve some extra performance).- Specified by:
setHibernateFlushMode
in interfaceSharedSessionContractImplementor
- Parameters:
flushMode
- the new flush mode
-
getHibernateFlushMode
public FlushMode getHibernateFlushMode()
Description copied from interface:SharedSessionContractImplementor
Get the current flush mode for this session.- Specified by:
getHibernateFlushMode
in interfaceQueryProducerImplementor
- Specified by:
getHibernateFlushMode
in interfaceSharedSessionContractImplementor
- Returns:
- The flush mode
-
getCacheMode
public CacheMode getCacheMode()
- Specified by:
getCacheMode
in interfaceQueryProducerImplementor
- Specified by:
getCacheMode
in interfaceSharedSessionContractImplementor
-
setCacheMode
public void setCacheMode(CacheMode cacheMode)
- Specified by:
setCacheMode
in interfaceSharedSessionContractImplementor
-
setCriteriaCopyTreeEnabled
public void setCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled)
- Specified by:
setCriteriaCopyTreeEnabled
in interfaceSharedSessionContractImplementor
-
isCriteriaCopyTreeEnabled
public boolean isCriteriaCopyTreeEnabled()
- Specified by:
isCriteriaCopyTreeEnabled
in interfaceSharedSessionContractImplementor
-
createQuery
public QueryImplementor createQuery(String queryString)
Description copied from interface:QueryProducer
Create aQuery
instance for the given HQL query, or HQL insert, update, or delete statement.- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
- Parameters:
queryString
- The HQL query- Returns:
- The
Query
instance for manipulation and execution - See Also:
EntityManager.createQuery(String)
-
createSelectionQuery
public SelectionQuery<?> createSelectionQuery(String hqlString)
Description copied from interface:QueryProducer
Create aSelectionQuery
reference for the given HQL. Only valid for select queries- Specified by:
createSelectionQuery
in interfaceQueryProducer
- See Also:
EntityManager.createQuery(String)
-
createSelectionQuery
public <R> SelectionQuery<R> createSelectionQuery(String hqlString, Class<R> expectedResultType)
Description copied from interface:QueryProducer
Create aSelectionQuery
reference for the given HQL. Only valid for select queries- Specified by:
createSelectionQuery
in interfaceQueryProducer
- See Also:
EntityManager.createQuery(String)
-
createSelectionQuery
public <R> SelectionQuery<R> createSelectionQuery(jakarta.persistence.criteria.CriteriaQuery<R> criteria)
Description copied from interface:QueryProducer
Create aSelectionQuery
reference for the given Criteria.- Specified by:
createSelectionQuery
in interfaceQueryProducer
- See Also:
EntityManager.createQuery(CriteriaQuery)
-
createQuery
public <T> QueryImplementor<T> createQuery(String queryString, Class<T> expectedResultType)
Description copied from interface:QueryProducer
Create a typedQuery
instance for the given HQL query string.The returned
Query
may be executed by callingQuery.getResultList()
orQuery.getSingleResult()
.- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
- Parameters:
queryString
- The HQL queryexpectedResultType
- The type of the query result- Returns:
- The Query instance for manipulation and execution
- See Also:
EntityManager.createQuery(String,Class)
-
createNativeQuery
public NativeQueryImpl createNativeQuery(String sqlString)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native (SQL) query- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- a native SQL query string- Returns:
- The
NativeQuery
instance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String)
-
createNativeQuery
public NativeQueryImplementor createNativeQuery(String sqlString, String resultSetMappingName)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native (SQL) query using implicit mapping to the specified Java type.- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- The native (SQL) query stringresultSetMappingName
- The explicit result mapping name- Returns:
- The NativeQuery instance for manipulation and execution
- See Also:
EntityManager.createNativeQuery(String,Class)
,SqlResultSetMapping
-
createNativeQuery
public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native (SQL) query using implicit mapping to the specified Java type.If the given class is an entity class, this method is equivalent to
createNativeQuery(sqlString).addEntity("alias1", resultClass)
.- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- The native (SQL) query stringresultClass
- The Java entity type to map results to- Returns:
- The NativeQuery instance for manipulation and execution
- See Also:
EntityManager.createNativeQuery(String,Class)
-
createNativeQuery
public <T> NativeQueryImplementor<T> createNativeQuery(String sqlString, Class<T> resultClass, String tableAlias)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native (SQL) query using implicit mapping to the specified Java type.If the given class is an entity class, this method is equivalent to
createNativeQuery(sqlString).addEntity(tableAlias, resultClass)
.- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- Native (SQL) query stringresultClass
- The Java entity type to map results totableAlias
- The table alias for columns in the result set- Returns:
- The
NativeQuery
instance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String,Class)
-
createNativeQuery
public <T> NativeQueryImplementor<T> createNativeQuery(String sqlString, String resultSetMappingName, Class<T> resultClass)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native (SQL) query using implicit mapping to the specified Java type.- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- The native (SQL) query stringresultSetMappingName
- The explicit result mapping name- Returns:
- The
NativeQuery
instance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String,Class)
,SqlResultSetMapping
-
getNamedQuery
public QueryImplementor getNamedQuery(String queryName)
Description copied from interface:QueryProducer
Create aQuery
instance for the named query.- Specified by:
getNamedQuery
in interfaceQueryProducer
- Specified by:
getNamedQuery
in interfaceQueryProducerImplementor
- Parameters:
queryName
- the name of a pre-defined, named query- Returns:
- The
Query
instance for manipulation and execution
-
createNamedQuery
public QueryImplementor createNamedQuery(String name)
Description copied from interface:QueryProducer
Create a typedQuery
instance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQuery
in interfaceQueryProducer
- Specified by:
createNamedQuery
in interfaceQueryProducerImplementor
- Parameters:
name
- the name of a pre-defined, named query- Returns:
- The
Query
instance for manipulation and execution - See Also:
EntityManager.createNamedQuery(String)
-
createNamedQuery
public <R> QueryImplementor<R> createNamedQuery(String name, Class<R> resultClass)
Description copied from interface:QueryProducer
Create a typedQuery
instance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQuery
in interfaceQueryProducer
- Specified by:
createNamedQuery
in interfaceQueryProducerImplementor
- Parameters:
name
- the name of a query defined in metadataresultClass
- the type of the query result- Returns:
- The
Query
instance for manipulation and execution - See Also:
EntityManager.createNamedQuery(String,Class)
-
createNamedSelectionQuery
public SelectionQuery<?> createNamedSelectionQuery(String queryName)
Description copied from interface:QueryProducer
Create aSelectionQuery
instance for the namedNamedQuery
- Specified by:
createNamedSelectionQuery
in interfaceQueryProducer
-
createNamedSelectionQuery
public <R> SelectionQuery<R> createNamedSelectionQuery(String queryName, Class<R> expectedResultType)
Description copied from interface:QueryProducer
Create aSelectionQuery
instance for the namedNamedQuery
with the expected result-type- Specified by:
createNamedSelectionQuery
in interfaceQueryProducer
-
doWork
public void doWork(Work work) throws HibernateException
Description copied from interface:SharedSessionContract
Perform work using theConnection
underlying by this session.- Specified by:
doWork
in interfaceSharedSessionContract
- Parameters:
work
- The work to be performed.- Throws:
HibernateException
- Generally indicates wrappedSQLException
-
doReturningWork
public <T> T doReturningWork(ReturningWork<T> work) throws HibernateException
Description copied from interface:SharedSessionContract
Perform work using theConnection
underlying by this session, and return a result.- Specified by:
doReturningWork
in interfaceSharedSessionContract
- Type Parameters:
T
- The type of the result returned from the work- Parameters:
work
- The work to be performed.- Returns:
- the result of calling
ReturningWork.execute(java.sql.Connection)
. - Throws:
HibernateException
- Generally indicates wrappedSQLException
-
buildNamedQuery
protected <T> QueryImplementor<T> buildNamedQuery(String queryName, Class<T> resultType)
-
buildNamedQuery
protected QueryImplementor buildNamedQuery(String queryName, Function<NamedSqmQueryMemento,SqmQueryImplementor> namedSqmHandler, Function<NamedNativeQueryMemento,NativeQueryImplementor> namedNativeHandler)
-
applyQuerySettingsAndHints
protected void applyQuerySettingsAndHints(SelectionQuery<?> query)
-
applyQuerySettingsAndHints
protected void applyQuerySettingsAndHints(Query<?> query)
-
getNamedNativeQuery
public NativeQueryImplementor getNamedNativeQuery(String queryName)
Description copied from interface:QueryProducer
Get aNativeQuery
instance for a named native SQL query- Specified by:
getNamedNativeQuery
in interfaceQueryProducer
- Specified by:
getNamedNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
queryName
- The name of the pre-defined query- Returns:
- The
NativeQuery
instance for manipulation and execution
-
getNamedNativeQuery
public NativeQueryImplementor getNamedNativeQuery(String queryName, String resultSetMapping)
Description copied from interface:QueryProducer
Get aNativeQuery
instance for a named native SQL query- Specified by:
getNamedNativeQuery
in interfaceQueryProducer
- Specified by:
getNamedNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
queryName
- The name of the pre-defined query- Returns:
- The
NativeQuery
instance for manipulation and execution
-
createMutationQuery
public MutationQuery createMutationQuery(String hqlString)
Description copied from interface:QueryProducer
Create a MutationQuery reference for the given HQL insert, update, or delete statement.- Specified by:
createMutationQuery
in interfaceQueryProducer
- Specified by:
createMutationQuery
in interfaceQueryProducerImplementor
-
createNativeMutationQuery
public MutationQuery createNativeMutationQuery(String sqlString)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native (SQL) statement- Specified by:
createNativeMutationQuery
in interfaceQueryProducer
- Specified by:
createNativeMutationQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- a native SQL statement string- Returns:
- The NativeQuery instance for manipulation and execution
-
createNamedMutationQuery
public MutationQuery createNamedMutationQuery(String queryName)
Description copied from interface:QueryProducer
Create aMutationQuery
instance for the given named insert, update, or delete HQL query. The named query might be defined as HQL) or native-SQL.- Specified by:
createNamedMutationQuery
in interfaceQueryProducer
- Specified by:
createNamedMutationQuery
in interfaceQueryProducerImplementor
-
createMutationQuery
public MutationQuery createMutationQuery(jakarta.persistence.criteria.CriteriaUpdate updateQuery)
Description copied from interface:QueryProducer
Create aMutationQuery
from the given update criteria tree- Specified by:
createMutationQuery
in interfaceQueryProducer
- Specified by:
createMutationQuery
in interfaceQueryProducerImplementor
-
createMutationQuery
public MutationQuery createMutationQuery(jakarta.persistence.criteria.CriteriaDelete deleteQuery)
Description copied from interface:QueryProducer
Create aMutationQuery
from the given delete criteria tree- Specified by:
createMutationQuery
in interfaceQueryProducer
- Specified by:
createMutationQuery
in interfaceQueryProducerImplementor
-
createMutationQuery
public MutationQuery createMutationQuery(JpaCriteriaInsertSelect insertSelect)
Description copied from interface:QueryProducer
Create aMutationQuery
from the given insert-select criteria tree- Specified by:
createMutationQuery
in interfaceQueryProducer
-
getNamedProcedureCall
public ProcedureCall getNamedProcedureCall(String name)
Description copied from interface:SharedSessionContract
Obtain aProcedureCall
based on a named template- Specified by:
getNamedProcedureCall
in interfaceSharedSessionContract
- Parameters:
name
- The name given to the template- Returns:
- The ProcedureCall
- See Also:
NamedStoredProcedureQuery
-
createNamedStoredProcedureQuery
public ProcedureCall createNamedStoredProcedureQuery(String name)
Description copied from interface:SharedSessionContract
Obtain aProcedureCall
based on a named template- Specified by:
createNamedStoredProcedureQuery
in interfaceSharedSessionContract
- Parameters:
name
- The name given to the template- Returns:
- The ProcedureCall
- See Also:
NamedStoredProcedureQuery
-
createStoredProcedureCall
public ProcedureCall createStoredProcedureCall(String procedureName)
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure.- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
public ProcedureCall createStoredProcedureCall(String procedureName, Class<?>... resultClasses)
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.resultClasses
- The entity(s) to map the result on to.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
public ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings)
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.resultSetMappings
- The explicit result set mapping(s) to use for mapping the results- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
public ProcedureCall createStoredProcedureQuery(String procedureName)
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure.- Specified by:
createStoredProcedureQuery
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
public ProcedureCall createStoredProcedureQuery(String procedureName, Class<?>... resultClasses)
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureQuery
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.resultClasses
- The entity(s) to map the result on to.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
public ProcedureCall createStoredProcedureQuery(String procedureName, String... resultSetMappings)
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureQuery
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.resultSetMappings
- The explicit result set mapping(s) to use for mapping the results- Returns:
- The representation of the procedure call.
-
getExceptionConverter
public ExceptionConverter getExceptionConverter()
Description copied from interface:SharedSessionContractImplementor
The converter associated to a Session might be lazily initialized: only invoke this getter when there is actual need to use it.- Specified by:
getExceptionConverter
in interfaceSharedSessionContractImplementor
- Returns:
- the ExceptionConverter for this Session.
-
getJdbcBatchSize
public Integer getJdbcBatchSize()
Description copied from interface:SharedSessionContract
Get the session-level JDBC batch size for the current session.- Specified by:
getJdbcBatchSize
in interfaceJdbcSessionOwner
- Specified by:
getJdbcBatchSize
in interfaceSharedSessionContract
- Returns:
- the current session-level JDBC batch size
- See Also:
SessionFactoryOptions.getJdbcBatchSize()
,SessionFactoryBuilder.applyJdbcBatchSize(int)
-
setJdbcBatchSize
public void setJdbcBatchSize(Integer jdbcBatchSize)
Description copied from interface:SharedSessionContract
Set the session-level JDBC batch size. Overrides thefactory-level
JDBC batch size defined by the configuration property "hibernate.jdbc.batch_size".- Specified by:
setJdbcBatchSize
in interfaceSharedSessionContract
- Parameters:
jdbcBatchSize
- the new session-level JDBC batch size- See Also:
SessionFactoryOptions.getJdbcBatchSize()
,SessionFactoryBuilder.applyJdbcBatchSize(int)
-
getCriteriaBuilder
public HibernateCriteriaBuilder getCriteriaBuilder()
Description copied from interface:SharedSessionContract
Return an instance ofCriteriaBuilder
.- Specified by:
getCriteriaBuilder
in interfaceSharedSessionContract
- Returns:
- an instance of CriteriaBuilder
-
createQuery
public <T> QueryImplementor<T> createQuery(jakarta.persistence.criteria.CriteriaQuery<T> criteriaQuery)
Description copied from interface:QueryProducer
Create aQuery
for the given JPACriteriaQuery
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
-
createQuery
public QueryImplementor createQuery(jakarta.persistence.criteria.CriteriaUpdate criteriaUpdate)
Description copied from interface:QueryProducer
Create aMutationQuery
for the given JPACriteriaUpdate
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
-
createQuery
public QueryImplementor createQuery(jakarta.persistence.criteria.CriteriaDelete criteriaDelete)
Description copied from interface:QueryProducer
Create aMutationQuery
for the given JPACriteriaDelete
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
-
-