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
.- See Also:
SessionImpl
,StatelessSessionImpl
, Serialized Form- Implementation Note:
- A
Session
or JPAEntityManager
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.
-
-
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 Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Transaction
accessTransaction()
Retrieves the currentTransaction
, or creates a new transaction if there is no transaction active.protected <T> void
addResultType(Class<T> resultClass, NativeQueryImplementor<T> query)
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 <Q> Q
buildNamedQuery(String queryName, Function<NamedSqmQueryMemento,Q> sqlCreator, Function<NamedNativeQueryMemento,Q> nativeCreator)
protected static void
checkMutationQuery(String hqlString, SqmStatement<?> sqmStatement)
void
checkOpen(boolean markForRollbackIfClosed)
Check whether the session is open, and if not: ifmarkForRollbackIfClosed = true
, mark the current transaction, if any, for rollback only, and throw anIllegalStateException
.protected void
checkOpenOrWaitingForAutoClose()
protected static <R> void
checkResultType(Class<R> expectedResultType, SqmSelectionQueryImpl<R> query)
protected static void
checkSelectionQuery(String hql, HqlInterpretation hqlInterpretation)
void
checkTransactionNeededForUpdateOperation(String exceptionMessage)
Check if an activeTransaction
is available before performing an update operation against the database.protected void
checkTransactionSynchStatus()
protected void
cleanupOnClose()
void
close()
End the session by releasing the JDBC connection and cleaning up.<T> RootGraphImplementor<T>
createEntityGraph(Class<T> rootType)
Create a new mutableEntityGraph
with only a root node.<T> RootGraph<T>
createEntityGraph(Class<T> rootType, String graphName)
Create a new mutable copy of the namedEntityGraph
, or returnnull
if there is no graph with the given name.RootGraphImplementor<?>
createEntityGraph(String graphName)
Create a new mutable copy of the namedEntityGraph
, or returnnull
if there is no graph with the given name.MutationQuery
createMutationQuery(CriteriaDelete deleteQuery)
Create aMutationQuery
from the given delete criteria treeMutationQuery
createMutationQuery(CriteriaUpdate updateQuery)
Create aMutationQuery
from the given update criteria treeMutationQuery
createMutationQuery(String hqlString)
Create aMutationQuery
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 given result type.ProcedureCall
createNamedStoredProcedureQuery(String name)
Obtain aProcedureCall
based on a named templateMutationQuery
createNativeMutationQuery(String sqlString)
Create aNativeQuery
instance for the given native SQL statement.NativeQueryImpl
createNativeQuery(String sqlString)
Create aNativeQuery
instance for the given native SQL query.NativeQueryImplementor
createNativeQuery(String sqlString, Class resultClass)
Create aNativeQuery
instance for the given native SQL query using an 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 an implicit mapping to the specified Java entity type.NativeQueryImplementor
createNativeQuery(String sqlString, String resultSetMappingName)
Create aNativeQuery
instance for the given native SQL query using an explicit 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 an explicit mapping to the specified Java type.protected <T> NativeQueryImplementor<T>
createNativeQueryImplementor(Class<T> resultType, NamedNativeQueryMemento memento)
protected NativeQueryImplementor<?>
createNativeQueryImplementor(String queryName, NamedNativeQueryMemento memento)
QueryImplementor
createQuery(CriteriaDelete criteriaDelete)
Create aMutationQuery
for the given JPACriteriaDelete
<T> QueryImplementor<T>
createQuery(CriteriaQuery<T> criteriaQuery)
Create aQuery
for the given JPACriteriaQuery
.QueryImplementor
createQuery(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 and given query result type.<R> SelectionQuery<R>
createSelectionQuery(CriteriaQuery<R> criteria)
Create aSelectionQuery
reference for the givenCriteriaQuery
.SelectionQuery<?>
createSelectionQuery(String hqlString)
Create aSelectionQuery
reference for the given HQLselect
statement.<R> SelectionQuery<R>
createSelectionQuery(String hqlString, Class<R> expectedResultType)
Create aSelectionQuery
instance for the given HQL query string and given query result type.protected <T> SqmQueryImplementor<T>
createSqmQueryImplementor(Class<T> resultType, NamedSqmQueryMemento memento)
protected SqmQueryImplementor<?>
createSqmQueryImplementor(String queryName, NamedSqmQueryMemento memento)
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)
Instantiate anEntityKey
with the given id and for the entity represented by the givenEntityPersister
.CacheMode
getCacheMode()
Get the currentCacheMode
for this session.CacheTransactionSynchronization
getCacheTransactionSynchronization()
The currentCacheTransactionSynchronization
associated with this 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()
protected TransactionImplementor
getCurrentTransaction()
RootGraphImplementor<?>
getEntityGraph(String graphName)
Retrieve the namedEntityGraph
as an immutable graph, or returnnull
if there is no graph with the given name.<T> List<EntityGraph<? super T>>
getEntityGraphs(Class<T> entityClass)
Retrieve all namedEntityGraph
s with the given type.EntityNameResolver
getEntityNameResolver()
SessionEventListenerManager
getEventListenerManager()
Get theSessionEventListenerManager
associated with this session.ExceptionConverter
getExceptionConverter()
Obtain anExceptionConverter
for reporting an error.SessionFactoryImplementor
getFactory()
Obtain the factory which created this session.FlushModeType
getFlushMode()
Get the currentFlushModeType
for this session.FlushMode
getHibernateFlushMode()
Get the currentFlushMode
for this session.Interceptor
getInterceptor()
Retrieves theInterceptor
associated with this session.Integer
getJdbcBatchSize()
Get the session-level JDBC batch size for the current session.JdbcConnectionAccess
getJdbcConnectionAccess()
JdbcCoordinator
getJdbcCoordinator()
Obtain theJdbcCoordinator
for this session.JdbcServices
getJdbcServices()
Obtain theJdbcServices
for the factory which created this session.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.protected NamedResultSetMappingMemento
getResultSetMappingMemento(String resultSetMappingName)
UUID
getSessionIdentifier()
Obtain aUUID
which uniquely identifies this session.Object
getSessionToken()
Obtain a "token" which uniquely identifies this session.String
getTenantIdentifier()
Obtain the tenant identifier associated with this session.Transaction
getTransaction()
Get theTransaction
instance associated with this session.TransactionCoordinator
getTransactionCoordinator()
Obtain the builder for TransactionCoordinator instancesprotected <R> HqlInterpretation
interpretHql(String hql, Class<R> resultType)
boolean
isClosed()
Determines whether the session is closed.boolean
isConnected()
Check if the session is currently connected.boolean
isCriteriaCopyTreeEnabled()
boolean
isJoinedToTransaction()
Check if the session is joined to the current transaction.boolean
isOpen()
Check if the session is still open.boolean
isOpenOrWaitingForAutoClose()
Determines whether the session is open or is waiting for auto-close.boolean
isTransactionInProgress()
Does this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?void
joinTransaction()
Join the currently-active JTA transaction.protected abstract Object
load(String entityName, Object identifier)
void
markForRollbackOnly()
Marks current transaction, if any, for rollback only.protected 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)
Set the currentCacheMode
for this session.protected void
setClosed()
void
setCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled)
void
setHibernateFlushMode(FlushMode flushMode)
Set the currentFlushMode
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.jdbc.LobCreationContext
fromContext
-
Methods inherited from interface org.hibernate.engine.spi.SharedSessionContractImplementor
afterOperation, afterScrollOperation, asEventSource, asSessionImplementor, asStatelessSession, autoFlushIfRequired, bestGuessEntityName, 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:
- the session-level JDBC batch size is set, or the factory-level setting otherwise
- 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
Obtain the factory which created this session.- Specified by:
getFactory
in interfaceQueryProducerImplementor
- Specified by:
getFactory
in interfaceSharedSessionContract
- Specified by:
getFactory
in interfaceSharedSessionContractImplementor
-
getInterceptor
public Interceptor getInterceptor()
Description copied from interface:SharedSessionContractImplementor
Retrieves theInterceptor
associated with this session.- Specified by:
getInterceptor
in interfaceSharedSessionContractImplementor
-
getJdbcCoordinator
public JdbcCoordinator getJdbcCoordinator()
Description copied from interface:SharedSessionContractImplementor
Obtain theJdbcCoordinator
for this session.- 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()
Description copied from interface:SharedSessionContractImplementor
Get theSessionEventListenerManager
associated with this session.- Specified by:
getEventListenerManager
in interfaceSharedSessionContractImplementor
-
getSessionIdentifier
public UUID getSessionIdentifier()
Description copied from interface:SharedSessionContractImplementor
Obtain aUUID
which uniquely identifies this session.The UUID is useful mainly for logging.
- Specified by:
getSessionIdentifier
in interfaceSharedSessionContractImplementor
-
getSessionToken
public Object getSessionToken()
Description copied from interface:SharedSessionContractImplementor
Obtain a "token" which uniquely identifies this session.- Specified by:
getSessionToken
in interfaceSharedSessionContractImplementor
-
getTenantIdentifier
public String getTenantIdentifier()
Description copied from interface:SharedSessionContract
Obtain the tenant identifier associated with this session.- Specified by:
getTenantIdentifier
in interfaceSharedSessionContract
- Returns:
- The tenant identifier associated with this session, or
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
Determines whether the session is closed.- 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
Determines 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
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.)
- 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 any, for rollback only.- Specified by:
markForRollbackOnly
in interfaceSharedSessionContractImplementor
-
isTransactionInProgress
public boolean isTransactionInProgress()
Description copied from interface:SharedSessionContractImplementor
Does this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?- Specified by:
isTransactionInProgress
in interfaceSharedSessionContractImplementor
-
checkTransactionNeededForUpdateOperation
public void checkTransactionNeededForUpdateOperation(String exceptionMessage)
Description copied from interface:SharedSessionContractImplementor
Check if an activeTransaction
is available before performing an update operation against the database.If an active transaction is necessary, but no transaction is active, a
TransactionRequiredException
is raised.- Specified by:
checkTransactionNeededForUpdateOperation
in interfaceSharedSessionContractImplementor
- Parameters:
exceptionMessage
- the message to use for theTransactionRequiredException
-
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
- See Also:
EntityManager.getTransaction()
-
accessTransaction
public Transaction accessTransaction()
Description copied from interface:SharedSessionContractImplementor
Retrieves the currentTransaction
, or creates a new transaction if there is no transaction active.This method 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 currentCacheTransactionSynchronization
associated with this session. This may benull
if the session is not currently associated with an active 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()
-
joinTransaction
public void joinTransaction()
Description copied from interface:SharedSessionContract
Join the currently-active JTA transaction.- Specified by:
joinTransaction
in interfaceSharedSessionContract
- See Also:
EntityManager.joinTransaction()
-
isJoinedToTransaction
public boolean isJoinedToTransaction()
Description copied from interface:SharedSessionContract
Check if the session is joined to the current transaction.- Specified by:
isJoinedToTransaction
in interfaceSharedSessionContract
- See Also:
SharedSessionContract.joinTransaction()
,EntityManager.isJoinedToTransaction()
-
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
Instantiate anEntityKey
with the given id and for the entity represented by the givenEntityPersister
.- 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:
MappingSettings.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:
JdbcSettings.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.
Thus, the storage
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:
JdbcSettings.JDBC_TIME_ZONE
- When
-
getJdbcServices
public JdbcServices getJdbcServices()
Description copied from interface:SharedSessionContractImplementor
Obtain theJdbcServices
for the factory which created this session.- Specified by:
getJdbcServices
in interfaceSharedSessionContractImplementor
-
getFlushMode
public FlushModeType getFlushMode()
Description copied from interface:SharedSessionContractImplementor
Get the currentFlushModeType
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 currentFlushMode
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's reasonable to set the session flush mode to
FlushMode.MANUAL
at the start of the session (in order skip some work and gain 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 currentFlushMode
for this session.- Specified by:
getHibernateFlushMode
in interfaceQueryProducerImplementor
- Specified by:
getHibernateFlushMode
in interfaceSharedSessionContractImplementor
- Returns:
- The flush mode
-
getCacheMode
public CacheMode getCacheMode()
Description copied from interface:SharedSessionContractImplementor
Get the currentCacheMode
for this session.- Specified by:
getCacheMode
in interfaceQueryProducerImplementor
- Specified by:
getCacheMode
in interfaceSharedSessionContractImplementor
-
setCacheMode
public void setCacheMode(CacheMode cacheMode)
Description copied from interface:SharedSessionContractImplementor
Set the currentCacheMode
for this session.- 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.If a query has no explicit
select
list, the select list is inferred:- if there is exactly one root entity in the
from
clause, then that root entity is the only element of the select list, or - otherwise, if there are multiple root entities in the
from
clause, then the select list contains every root entity and every non-fetch
joined entity.
- 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)
- if there is exactly one root entity in the
-
createSelectionQuery
public SelectionQuery<?> createSelectionQuery(String hqlString)
Description copied from interface:QueryProducer
Create aSelectionQuery
reference for the given HQLselect
statement.If the statement has no explicit
select
list, the select list is inferred:- if there is exactly one root entity in the
from
clause, then that root entity is the only element of the select list, or - otherwise, if there are multiple root entities in the
from
clause, then the select list contains every root entity and every non-fetch
joined entity.
- Specified by:
createSelectionQuery
in interfaceQueryProducer
- if there is exactly one root entity in the
-
interpretHql
protected <R> HqlInterpretation interpretHql(String hql, Class<R> resultType)
-
checkSelectionQuery
protected static void checkSelectionQuery(String hql, HqlInterpretation hqlInterpretation)
-
checkResultType
protected static <R> void checkResultType(Class<R> expectedResultType, SqmSelectionQueryImpl<R> query)
-
createSelectionQuery
public <R> SelectionQuery<R> createSelectionQuery(String hqlString, Class<R> expectedResultType)
Description copied from interface:QueryProducer
Create aSelectionQuery
instance for the given HQL query string and given query result type.- If the query has a single item in the
select
list, then the select item must be assignable to the given result type. - Otherwise, if there are multiple select items, then the
select items will be packaged into an instance of the
result type. The result type must have an appropriate
constructor with parameter types matching the select items,
or it must be one of the types
Object[]
,List
,Map
, orTuple
.
If a query has no explicit
select
list, the select list is inferred from the given query result type:- if the result type is an entity type, the query must have
exactly one root entity in the
from
clause, it must be assignable to the result type, and the inferred select list will contain just that entity, or - otherwise, the select list contains every root entity and
every non-
fetch
joined entity, and each query result will be packaged into an instance of the result type, just as specified above.
The returned
Query
may be executed by callingQuery.getResultList()
orQuery.getSingleResult()
.- Specified by:
createSelectionQuery
in interfaceQueryProducer
- Parameters:
hqlString
- The HQL query as a stringexpectedResultType
- TheClass
object representing the query result type- See Also:
EntityManager.createQuery(String)
- If the query has a single item in the
-
createSelectionQuery
public <R> SelectionQuery<R> createSelectionQuery(CriteriaQuery<R> criteria)
Description copied from interface:QueryProducer
Create aSelectionQuery
reference for the givenCriteriaQuery
.- 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 and given query result type.- If the query has a single item in the
select
list, then the select item must be assignable to the given result type. - Otherwise, if there are multiple select items, then the
select items will be packaged into an instance of the
result type. The result type must have an appropriate
constructor with parameter types matching the select items,
or it must be one of the types
Object[]
,List
,Map
, orTuple
.
If a query has no explicit
select
list, the select list is inferred from the given query result type:- if the result type is an entity type, the query must have
exactly one root entity in the
from
clause, it must be assignable to the result type, and the inferred select list will contain just that entity, or - otherwise, the select list contains every root entity and
every non-
fetch
joined entity, and each query result will be packaged into an instance of the result type, just as specified above.
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)
- If the query has a single item in the
-
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 an explicit mapping to the specified Java type.The given result set mapping name must identify a mapping defined by a
SqlResultSetMapping
annotation.- 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
-
getResultSetMappingMemento
protected NamedResultSetMappingMemento getResultSetMappingMemento(String resultSetMappingName)
-
createNativeQuery
public NativeQueryImplementor createNativeQuery(String sqlString, Class resultClass)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native SQL query using an implicit mapping to the specified Java type.- If the given class is an entity class, this method is equivalent
to
createNativeQuery(sqlString).addEntity(resultClass)
. - If the given class has a registered
JavaType
, then the query must return a result set with a single column whoseJdbcType
is compatible with thatJavaType
. - Otherwise, the select items will be packaged into an instance of
the result type. The result type must have an appropriate
constructor with parameter types matching the select items, or it
must be one of the types
Object[]
,List
,Map
, orTuple
.
- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- The native (SQL) query stringresultClass
- The Java type to map results to- Returns:
- The
NativeQuery
instance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String,Class)
- If the given class is an entity class, this method is equivalent
to
-
addResultType
protected <T> void addResultType(Class<T> resultClass, NativeQueryImplementor<T> query)
-
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 an implicit mapping to the specified Java entity type.The given class must be 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 class 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 an explicit mapping to the specified Java type.The given result set mapping name must identify a mapping defined by a
SqlResultSetMapping
annotation.- 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 predefined 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 predefined 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 given 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
-
applyQuerySettingsAndHints
protected void applyQuerySettingsAndHints(SelectionQuery<?> query)
-
applyQuerySettingsAndHints
protected void applyQuerySettingsAndHints(Query<?> query)
-
buildNamedQuery
protected <Q> Q buildNamedQuery(String queryName, Function<NamedSqmQueryMemento,Q> sqlCreator, Function<NamedNativeQueryMemento,Q> nativeCreator)
-
buildNamedQuery
protected <T> QueryImplementor<T> buildNamedQuery(String queryName, Class<T> resultType)
-
createNativeQueryImplementor
protected <T> NativeQueryImplementor<T> createNativeQueryImplementor(Class<T> resultType, NamedNativeQueryMemento memento)
-
createSqmQueryImplementor
protected <T> SqmQueryImplementor<T> createSqmQueryImplementor(Class<T> resultType, NamedSqmQueryMemento memento)
-
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 predefined 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 predefined query- Returns:
- The
NativeQuery
instance for manipulation and execution
-
createMutationQuery
public MutationQuery createMutationQuery(String hqlString)
Description copied from interface:QueryProducer
Create aMutationQuery
reference for the given HQL insert, update, or delete statement.- Specified by:
createMutationQuery
in interfaceQueryProducer
- Specified by:
createMutationQuery
in interfaceQueryProducerImplementor
-
checkMutationQuery
protected static void checkMutationQuery(String hqlString, SqmStatement<?> sqmStatement)
-
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
-
createNativeQueryImplementor
protected NativeQueryImplementor<?> createNativeQueryImplementor(String queryName, NamedNativeQueryMemento memento)
-
createSqmQueryImplementor
protected SqmQueryImplementor<?> createSqmQueryImplementor(String queryName, NamedSqmQueryMemento memento)
-
createMutationQuery
public MutationQuery createMutationQuery(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(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
Obtain anExceptionConverter
for reporting an error.The converter associated to a session might be lazily initialized, so only invoke this getter when there's an 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. Override the factory-level JDBC batch size controlled by the configuration property "hibernate.jdbc.batch_size".- Specified by:
setJdbcBatchSize
in interfaceSharedSessionContract
- Parameters:
jdbcBatchSize
- the new session-level JDBC batch size- See Also:
BatchSettings.STATEMENT_BATCH_SIZE
,SessionFactoryOptions.getJdbcBatchSize()
,SessionFactoryBuilder.applyJdbcBatchSize(int)
-
getCriteriaBuilder
public HibernateCriteriaBuilder getCriteriaBuilder()
Description copied from interface:SharedSessionContract
- Specified by:
getCriteriaBuilder
in interfaceSharedSessionContract
- Returns:
- an instance of
HibernateCriteriaBuilder
- See Also:
SessionFactory.getCriteriaBuilder()
-
createQuery
public <T> QueryImplementor<T> createQuery(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(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(CriteriaDelete criteriaDelete)
Description copied from interface:QueryProducer
Create aMutationQuery
for the given JPACriteriaDelete
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
-
createEntityGraph
public <T> RootGraphImplementor<T> createEntityGraph(Class<T> rootType)
Description copied from interface:SharedSessionContract
Create a new mutableEntityGraph
with only a root node.- Specified by:
createEntityGraph
in interfaceSharedSessionContract
- Parameters:
rootType
- the root entity class of the graph
-
createEntityGraph
public <T> RootGraph<T> createEntityGraph(Class<T> rootType, String graphName)
Description copied from interface:SharedSessionContract
Create a new mutable copy of the namedEntityGraph
, or returnnull
if there is no graph with the given name.- Specified by:
createEntityGraph
in interfaceSharedSessionContract
- Parameters:
rootType
- the root entity class of the graphgraphName
- the name of the graph- See Also:
EntityManagerFactory.addNamedEntityGraph(String, EntityGraph)
-
createEntityGraph
public RootGraphImplementor<?> createEntityGraph(String graphName)
Description copied from interface:SharedSessionContract
Create a new mutable copy of the namedEntityGraph
, or returnnull
if there is no graph with the given name.- Specified by:
createEntityGraph
in interfaceSharedSessionContract
- Parameters:
graphName
- the name of the graph- See Also:
EntityManagerFactory.addNamedEntityGraph(String, EntityGraph)
-
getEntityGraph
public RootGraphImplementor<?> getEntityGraph(String graphName)
Description copied from interface:SharedSessionContract
Retrieve the namedEntityGraph
as an immutable graph, or returnnull
if there is no graph with the given name.- Specified by:
getEntityGraph
in interfaceSharedSessionContract
- Parameters:
graphName
- the name of the graph- See Also:
EntityManagerFactory.addNamedEntityGraph(String, EntityGraph)
-
getEntityGraphs
public <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass)
Description copied from interface:SharedSessionContract
Retrieve all namedEntityGraph
s with the given type.- Specified by:
getEntityGraphs
in interfaceSharedSessionContract
- See Also:
EntityManagerFactory.addNamedEntityGraph(String, EntityGraph)
-
-