Package org.hibernate.internal
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 ofSharedSessionContractandSharedSessionContractImplementor. Intended for concrete implementations ofSessionandStatelessSession. 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 booleanclosedprotected FastSessionServicesfastSessionServicesprotected booleanwaitingForAutoClose
-
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 TransactionaccessTransaction()Provides access to the underlying transaction or creates a new transaction if one does not already exist or is active.protected voidaddSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)voidafterTransactionCompletion(boolean successful, boolean delayed)An after-completion callback to the owner.protected voidapplyQuerySettingsAndHints(Query<?> query)protected voidapplyQuerySettingsAndHints(SelectionQuery<?> query)voidbeforeTransactionCompletion()A before-completion callback to the owner.TransactionbeginTransaction()Begin a unit of work and return the associatedTransactionobject.protected <T> QueryImplementor<T>buildNamedQuery(String queryName, Class<T> resultType)protected QueryImplementorbuildNamedQuery(String queryName, Function<NamedSqmQueryMemento,SqmQueryImplementor> namedSqmHandler, Function<NamedNativeQueryMemento,NativeQueryImplementor> namedNativeHandler)voidcheckOpen(boolean markForRollbackIfClosed)Performs a check whether the Session is open, and if not: ifmarkForRollbackIfClosedis true, marks current transaction (if one) for rollback only throws an IllegalStateException (JPA defines the exception type)protected voidcheckOpenOrWaitingForAutoClose()voidcheckTransactionNeededForUpdateOperation(String exceptionMessage)Check if an active Transaction is necessary for the update operation to be executed.protected voidcheckTransactionSynchStatus()protected voidcleanupOnClose()voidclose()End the session by releasing the JDBC connection and cleaning up.MutationQuerycreateMutationQuery(jakarta.persistence.criteria.CriteriaDelete deleteQuery)Create aMutationQueryfrom the given delete criteria treeMutationQuerycreateMutationQuery(jakarta.persistence.criteria.CriteriaUpdate updateQuery)Create aMutationQueryfrom the given update criteria treeMutationQuerycreateMutationQuery(String hqlString)Create a MutationQuery reference for the given HQL insert, update, or delete statement.MutationQuerycreateMutationQuery(JpaCriteriaInsertSelect insertSelect)Create aMutationQueryfrom the given insert-select criteria treeMutationQuerycreateNamedMutationQuery(String queryName)Create aMutationQueryinstance for the given named insert, update, or delete HQL query.QueryImplementorcreateNamedQuery(String name)Create a typedQueryinstance for the given named query.<R> QueryImplementor<R>createNamedQuery(String name, Class<R> resultClass)Create a typedQueryinstance for the given named query.SelectionQuery<?>createNamedSelectionQuery(String queryName)Create aSelectionQueryinstance for the namedNamedQuery<R> SelectionQuery<R>createNamedSelectionQuery(String queryName, Class<R> expectedResultType)Create aSelectionQueryinstance for the namedNamedQuerywith the expected result-typeProcedureCallcreateNamedStoredProcedureQuery(String name)Obtain aProcedureCallbased on a named templateMutationQuerycreateNativeMutationQuery(String sqlString)Create aNativeQueryinstance for the given native (SQL) statementNativeQueryImplcreateNativeQuery(String sqlString)Create aNativeQueryinstance for the given native (SQL) queryNativeQueryImplementorcreateNativeQuery(String sqlString, Class resultClass)Create aNativeQueryinstance 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 aNativeQueryinstance for the given native (SQL) query using implicit mapping to the specified Java type.NativeQueryImplementorcreateNativeQuery(String sqlString, String resultSetMappingName)Create aNativeQueryinstance 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 aNativeQueryinstance for the given native (SQL) query using implicit mapping to the specified Java type.QueryImplementorcreateQuery(jakarta.persistence.criteria.CriteriaDelete criteriaDelete)Create aMutationQueryfor the given JPACriteriaDelete<T> QueryImplementor<T>createQuery(jakarta.persistence.criteria.CriteriaQuery<T> criteriaQuery)Create aQueryfor the given JPACriteriaQueryQueryImplementorcreateQuery(jakarta.persistence.criteria.CriteriaUpdate criteriaUpdate)Create aMutationQueryfor the given JPACriteriaUpdateQueryImplementorcreateQuery(String queryString)Create aQueryinstance for the given HQL query, or HQL insert, update, or delete statement.<T> QueryImplementor<T>createQuery(String queryString, Class<T> expectedResultType)Create a typedQueryinstance for the given HQL query string.<R> SelectionQuery<R>createSelectionQuery(jakarta.persistence.criteria.CriteriaQuery<R> criteria)Create aSelectionQueryreference for the given Criteria.SelectionQuery<?>createSelectionQuery(String hqlString)Create aSelectionQueryreference for the given HQL.<R> SelectionQuery<R>createSelectionQuery(String hqlString, Class<R> expectedResultType)Create aSelectionQueryreference for the given HQL.ProcedureCallcreateStoredProcedureCall(String procedureName)Create aProcedureCallto a stored procedure.ProcedureCallcreateStoredProcedureCall(String procedureName, Class<?>... resultClasses)Create aProcedureCallto a stored procedure with the given result set entity mappings.ProcedureCallcreateStoredProcedureCall(String procedureName, String... resultSetMappings)Create aProcedureCallto a stored procedure with the given result set entity mappings.ProcedureCallcreateStoredProcedureQuery(String procedureName)Create aProcedureCallto a stored procedure.ProcedureCallcreateStoredProcedureQuery(String procedureName, Class<?>... resultClasses)Create aProcedureCallto a stored procedure with the given result set entity mappings.ProcedureCallcreateStoredProcedureQuery(String procedureName, String... resultSetMappings)Create aProcedureCallto a stored procedure with the given result set entity mappings.protected voiddelayedAfterCompletion()<T> TdoReturningWork(ReturningWork<T> work)Perform work using theConnectionunderlying by this session, and return a result.voiddoWork(Work work)Perform work using theConnectionunderlying by this session.<T> Texecute(LobCreationContext.Callback<T> callback)Execute the given callback, making sure it has access to a viable JDBCConnection.EntityKeygenerateEntityKey(Object id, EntityPersister persister)Hide the changing requirements of entity key creationCacheModegetCacheMode()CacheTransactionSynchronizationgetCacheTransactionSynchronization()The current CacheTransactionContext associated with the Session.IntegergetConfiguredJdbcBatchSize()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.HibernateCriteriaBuildergetCriteriaBuilder()Return an instance ofCriteriaBuilder.protected TransactionImplementorgetCurrentTransaction()EntityNameResolvergetEntityNameResolver()SessionEventListenerManagergetEventListenerManager()ExceptionConvertergetExceptionConverter()The converter associated to a Session might be lazily initialized: only invoke this getter when there is actual need to use it.SessionFactoryImplementorgetFactory()Get the creatingSessionFactoryImplementorjakarta.persistence.FlushModeTypegetFlushMode()Get the flush mode for this session.FlushModegetHibernateFlushMode()Get the current flush mode for this session.InterceptorgetInterceptor()Retrieves the interceptor currently in use by this event source.IntegergetJdbcBatchSize()Get the session-level JDBC batch size for the current session.JdbcConnectionAccessgetJdbcConnectionAccess()JdbcCoordinatorgetJdbcCoordinator()JdbcServicesgetJdbcServices()JdbcSessionContextgetJdbcSessionContext()TimeZonegetJdbcTimeZone()The JDBCTimeZoneused when persisting Timestamp and DateTime properties into the database.LobCreatorgetLobCreator()Obtain access to theLobCreatorNativeQueryImplementorgetNamedNativeQuery(String queryName)Get aNativeQueryinstance for a named native SQL queryNativeQueryImplementorgetNamedNativeQuery(String queryName, String resultSetMapping)Get aNativeQueryinstance for a named native SQL queryProcedureCallgetNamedProcedureCall(String name)Obtain aProcedureCallbased on a named templateQueryImplementorgetNamedQuery(String queryName)Create aQueryinstance for the named query.intgetPreferredSqlTypeCodeForBoolean()Get the JDBCtype codeused to bind a null boolean valueUUIDgetSessionIdentifier()A UUID associated with each Session.ObjectgetSessionToken()A "token" that is unique to this Session.StringgetTenantIdentifier()The multi-tenancy tenant identifier, if one.TransactiongetTransaction()Get theTransactioninstance associated with this session.TransactionCoordinatorgetTransactionCoordinator()Obtain the builder for TransactionCoordinator instanceslonggetTransactionStartTimestamp()A "timestamp" at or before the start of the current transaction.booleanisClosed()Checks whether the session is closed.booleanisConnected()Check if the session is currently connected.booleanisCriteriaCopyTreeEnabled()booleanisOpen()Check if the session is still open.booleanisOpenOrWaitingForAutoClose()Checks whether the session is open or is waiting for auto-closebooleanisTransactionInProgress()Does thisSessionhave an active Hibernate transaction or is there a JTA transaction in progress?protected abstract Objectload(String entityName, Object identifier)voidmarkForRollbackOnly()Marks current transaction (if one) for rollback onlyprotected voidprepareForAutoClose()voidprepareForQueryExecution(boolean requiresTxn)Prepare for the execution of aQueryorProcedureCallprotected voidpulseTransactionCoordinator()protected voidremoveSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator)voidsetCacheMode(CacheMode cacheMode)protected voidsetClosed()voidsetCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled)voidsetHibernateFlushMode(FlushMode flushMode)Set the flush mode for this session.voidsetJdbcBatchSize(Integer jdbcBatchSize)Set the session-level JDBC batch size.booleanshouldAutoJoinTransaction()Indicates whether an active transaction should be automatically joined.protected booleanshouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared)voidstartTransactionBoundary()Callback indicating recognition of entering into a transactional context whether that is explicitly via the HibernateTransactionAPI or via registration of Hibernate's JTA Synchronization impl with a JTA TransactionbooleanuseStreamForLobBinding()Should streams 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, autoFlushIfRequired, bestGuessEntityName, checkOpen, flush, getContextEntityIdentifier, getEntityPersister, getEntityUsingInterceptor, getLoadQueryInfluencers, getPersistenceContext, getPersistenceContextInternal, getSession, getSessionFactory, getTypeConfiguration, guessEntityName, immediateLoad, initializeCollection, instantiate, instantiate, internalLoad, isAutoCloseSessionEnabled, isDefaultReadOnly, isEnforcingFetchGraph, isEventSource, 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:
getConfiguredJdbcBatchSizein interfaceSharedSessionContractImplementor- Returns:
- Session-level or 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.OptionsIndicates whether an active transaction should be automatically joined. Only relevant for JTA-based TransactionCoordinator instances.- Specified by:
shouldAutoJoinTransactionin interfaceTransactionCoordinatorBuilder.Options- Returns:
trueindicates the active transaction should be auto joined;falseindicates it should not (untilTransactionCoordinator.explicitJoin()is called).
-
getFactory
public SessionFactoryImplementor getFactory()
Description copied from interface:SharedSessionContractImplementorGet the creatingSessionFactoryImplementor- Specified by:
getFactoryin interfaceQueryProducerImplementor- Specified by:
getFactoryin interfaceSharedSessionContractImplementor
-
getInterceptor
public Interceptor getInterceptor()
Description copied from interface:SharedSessionContractImplementorRetrieves the interceptor currently in use by this event source.- Specified by:
getInterceptorin interfaceSharedSessionContractImplementor- Returns:
- The interceptor.
-
getJdbcCoordinator
public JdbcCoordinator getJdbcCoordinator()
- Specified by:
getJdbcCoordinatorin interfaceSharedSessionContractImplementor
-
getTransactionCoordinator
public TransactionCoordinator getTransactionCoordinator()
Description copied from interface:JdbcSessionOwnerObtain the builder for TransactionCoordinator instances- Specified by:
getTransactionCoordinatorin interfaceJdbcSessionOwner- Returns:
- The TransactionCoordinatorBuilder
-
getJdbcSessionContext
public JdbcSessionContext getJdbcSessionContext()
- Specified by:
getJdbcSessionContextin interfaceJdbcSessionOwner
-
getEntityNameResolver
public EntityNameResolver getEntityNameResolver()
-
getEventListenerManager
public SessionEventListenerManager getEventListenerManager()
- Specified by:
getEventListenerManagerin interfaceSharedSessionContractImplementor
-
getSessionIdentifier
public UUID getSessionIdentifier()
Description copied from interface:SharedSessionContractImplementorA UUID associated with each Session. Useful mainly for logging.- Specified by:
getSessionIdentifierin interfaceSharedSessionContractImplementor- Returns:
- The UUID
-
getSessionToken
public Object getSessionToken()
Description copied from interface:SharedSessionContractImplementorA "token" that is unique to this Session.- Specified by:
getSessionTokenin interfaceSharedSessionContractImplementor- Returns:
- The token
-
getTenantIdentifier
public String getTenantIdentifier()
Description copied from interface:SharedSessionContractImplementorThe multi-tenancy tenant identifier, if one.- Specified by:
getTenantIdentifierin interfaceSharedSessionContract- Specified by:
getTenantIdentifierin interfaceSharedSessionContractImplementor- Returns:
- The tenant identifier; may be
null
-
isOpen
public boolean isOpen()
Description copied from interface:SharedSessionContractCheck if the session is still open.- Specified by:
isOpenin interfaceSharedSessionContract- Returns:
- boolean
-
isClosed
public boolean isClosed()
Description copied from interface:SharedSessionContractImplementorChecks 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:
isClosedin interfaceSharedSessionContractImplementor- Returns:
trueif the session is closed;falseotherwise.
-
close
public void close()
Description copied from interface:SharedSessionContractEnd the session by releasing the JDBC connection and cleaning up.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceSharedSessionContract
-
setClosed
protected void setClosed()
-
shouldCloseJdbcCoordinatorOnClose
protected boolean shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared)
-
cleanupOnClose
protected void cleanupOnClose()
-
isOpenOrWaitingForAutoClose
public boolean isOpenOrWaitingForAutoClose()
Description copied from interface:SharedSessionContractImplementorChecks whether the session is open or is waiting for auto-close- Specified by:
isOpenOrWaitingForAutoClosein interfaceSharedSessionContractImplementor- Returns:
trueif the session is closed or if it's waiting for auto-close;falseotherwise.
-
checkOpen
public void checkOpen(boolean markForRollbackIfClosed)
Description copied from interface:SharedSessionContractImplementorPerforms a check whether the Session is open, and if not:- if
markForRollbackIfClosedis true, marks current transaction (if one) for rollback only - throws an IllegalStateException (JPA defines the exception type)
- Specified by:
checkOpenin interfaceSharedSessionContractImplementor
- if
-
prepareForQueryExecution
public void prepareForQueryExecution(boolean requiresTxn)
Description copied from interface:SharedSessionContractImplementorPrepare for the execution of aQueryorProcedureCall- Specified by:
prepareForQueryExecutionin interfaceSharedSessionContractImplementor
-
checkOpenOrWaitingForAutoClose
protected void checkOpenOrWaitingForAutoClose()
-
markForRollbackOnly
public void markForRollbackOnly()
Description copied from interface:SharedSessionContractImplementorMarks current transaction (if one) for rollback only- Specified by:
markForRollbackOnlyin interfaceSharedSessionContractImplementor
-
isTransactionInProgress
public boolean isTransactionInProgress()
Description copied from interface:SharedSessionContractImplementorDoes thisSessionhave an active Hibernate transaction or is there a JTA transaction in progress?- Specified by:
isTransactionInProgressin interfaceSharedSessionContractImplementor
-
checkTransactionNeededForUpdateOperation
public void checkTransactionNeededForUpdateOperation(String exceptionMessage)
Description copied from interface:SharedSessionContractImplementorCheck 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:
checkTransactionNeededForUpdateOperationin interfaceSharedSessionContractImplementor- Parameters:
exceptionMessage- the message to use for the TransactionRequiredException
-
getTransaction
public Transaction getTransaction() throws HibernateException
Description copied from interface:SharedSessionContractGet theTransactioninstance associated with this session.- Specified by:
getTransactionin interfaceSharedSessionContract- Returns:
- a Transaction instance
- Throws:
HibernateException
-
accessTransaction
public Transaction accessTransaction()
Description copied from interface:SharedSessionContractImplementorProvides 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:
accessTransactionin interfaceSharedSessionContractImplementor- Returns:
- the transaction
-
startTransactionBoundary
public void startTransactionBoundary()
Description copied from interface:JdbcSessionOwnerCallback indicating recognition of entering into a transactional context whether that is explicitly via the HibernateTransactionAPI or via registration of Hibernate's JTA Synchronization impl with a JTA Transaction- Specified by:
startTransactionBoundaryin interfaceJdbcSessionOwner
-
beforeTransactionCompletion
public void beforeTransactionCompletion()
Description copied from interface:JdbcSessionOwnerA before-completion callback to the owner.- Specified by:
beforeTransactionCompletionin interfaceJdbcSessionOwner
-
afterTransactionCompletion
public void afterTransactionCompletion(boolean successful, boolean delayed)Description copied from interface:JdbcSessionOwnerAn after-completion callback to the owner.- Specified by:
afterTransactionCompletionin 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:SharedSessionContractImplementorThe current CacheTransactionContext associated with the Session. This may returnnullwhen the Session is not currently part of a transaction.- Specified by:
getCacheTransactionSynchronizationin interfaceSharedSessionContractImplementor
-
getTransactionStartTimestamp
public long getTransactionStartTimestamp()
Description copied from interface:SharedSessionContractImplementorA "timestamp" at or before the start of the current transaction.- Specified by:
getTransactionStartTimestampin interfaceSharedSessionContractImplementor
-
beginTransaction
public Transaction beginTransaction()
Description copied from interface:SharedSessionContractBegin a unit of work and return the associatedTransactionobject. 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:
beginTransactionin interfaceSharedSessionContract- Returns:
- a
Transactioninstance - 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:SharedSessionContractCheck if the session is currently connected.- Specified by:
isConnectedin interfaceSharedSessionContract- Returns:
- boolean
-
getJdbcConnectionAccess
public JdbcConnectionAccess getJdbcConnectionAccess()
- Specified by:
getJdbcConnectionAccessin interfaceJdbcSessionOwner
-
generateEntityKey
public EntityKey generateEntityKey(Object id, EntityPersister persister)
Description copied from interface:SharedSessionContractImplementorHide the changing requirements of entity key creation- Specified by:
generateEntityKeyin interfaceSharedSessionContractImplementor- Parameters:
id- The entity idpersister- The entity persister- Returns:
- The entity key
-
useStreamForLobBinding
public boolean useStreamForLobBinding()
Description copied from interface:WrapperOptionsShould streams be used for binding LOB values.- Specified by:
useStreamForLobBindingin interfaceWrapperOptions- Returns:
true/false
-
getPreferredSqlTypeCodeForBoolean
public int getPreferredSqlTypeCodeForBoolean()
Description copied from interface:WrapperOptionsGet the JDBCtype codeused to bind a null boolean value- Specified by:
getPreferredSqlTypeCodeForBooleanin interfaceWrapperOptions
-
getLobCreator
public LobCreator getLobCreator()
Description copied from interface:WrapperOptionsObtain access to theLobCreator- Specified by:
getLobCreatorin interfaceWrapperOptions- Returns:
- The LOB creator
-
execute
public <T> T execute(LobCreationContext.Callback<T> callback)
Description copied from interface:LobCreationContextExecute the given callback, making sure it has access to a viable JDBCConnection.- Specified by:
executein 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:WrapperOptionsThe JDBCTimeZoneused when persisting Timestamp and DateTime properties into the database. This setting is used when storing timestamps using thePreparedStatement.setTimestamp(int, Timestamp, Calendar)method. This way, the storageTimeZonecan differ from the default JVM TimeZone given byTimeZone.getDefault().- Specified by:
getJdbcTimeZonein interfaceWrapperOptions- Returns:
- JDBC
TimeZone
-
getJdbcServices
public JdbcServices getJdbcServices()
- Specified by:
getJdbcServicesin interfaceSharedSessionContractImplementor
-
getFlushMode
public jakarta.persistence.FlushModeType getFlushMode()
Description copied from interface:SharedSessionContractImplementorGet 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 JPAFlushModeTyperather than Hibernate'sFlushMode. For the former behavior, useSharedSessionContractImplementor.getHibernateFlushMode()instead.- Specified by:
getFlushModein interfaceSharedSessionContractImplementor- Returns:
- The FlushModeType in effect for this Session.
-
setHibernateFlushMode
public void setHibernateFlushMode(FlushMode flushMode)
Description copied from interface:SharedSessionContractImplementorSet 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 toFlushMode.MANUALat the start of the session (in order to achieve some extra performance).- Specified by:
setHibernateFlushModein interfaceSharedSessionContractImplementor- Parameters:
flushMode- the new flush mode
-
getHibernateFlushMode
public FlushMode getHibernateFlushMode()
Description copied from interface:SharedSessionContractImplementorGet the current flush mode for this session.- Specified by:
getHibernateFlushModein interfaceQueryProducerImplementor- Specified by:
getHibernateFlushModein interfaceSharedSessionContractImplementor- Returns:
- The flush mode
-
getCacheMode
public CacheMode getCacheMode()
- Specified by:
getCacheModein interfaceQueryProducerImplementor- Specified by:
getCacheModein interfaceSharedSessionContractImplementor
-
setCacheMode
public void setCacheMode(CacheMode cacheMode)
- Specified by:
setCacheModein interfaceSharedSessionContractImplementor
-
setCriteriaCopyTreeEnabled
public void setCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled)
- Specified by:
setCriteriaCopyTreeEnabledin interfaceSharedSessionContractImplementor
-
isCriteriaCopyTreeEnabled
public boolean isCriteriaCopyTreeEnabled()
- Specified by:
isCriteriaCopyTreeEnabledin interfaceSharedSessionContractImplementor
-
createQuery
public QueryImplementor createQuery(String queryString)
Description copied from interface:QueryProducerCreate aQueryinstance for the given HQL query, or HQL insert, update, or delete statement.- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor- Parameters:
queryString- The HQL query- Returns:
- The
Queryinstance for manipulation and execution - See Also:
EntityManager.createQuery(String)
-
createSelectionQuery
public SelectionQuery<?> createSelectionQuery(String hqlString)
Description copied from interface:QueryProducerCreate aSelectionQueryreference for the given HQL. Only valid for select queries- Specified by:
createSelectionQueryin interfaceQueryProducer- See Also:
EntityManager.createQuery(String)
-
createSelectionQuery
public <R> SelectionQuery<R> createSelectionQuery(String hqlString, Class<R> expectedResultType)
Description copied from interface:QueryProducerCreate aSelectionQueryreference for the given HQL. Only valid for select queries- Specified by:
createSelectionQueryin interfaceQueryProducer- See Also:
EntityManager.createQuery(String)
-
createSelectionQuery
public <R> SelectionQuery<R> createSelectionQuery(jakarta.persistence.criteria.CriteriaQuery<R> criteria)
Description copied from interface:QueryProducerCreate aSelectionQueryreference for the given Criteria.- Specified by:
createSelectionQueryin interfaceQueryProducer- See Also:
EntityManager.createQuery(CriteriaQuery)
-
createQuery
public <T> QueryImplementor<T> createQuery(String queryString, Class<T> expectedResultType)
Description copied from interface:QueryProducerCreate a typedQueryinstance for the given HQL query string.The returned
Querymay be executed by callingQuery.getResultList()orQuery.getSingleResult().- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin 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:QueryProducerCreate aNativeQueryinstance for the given native (SQL) query- Specified by:
createNativeQueryin interfaceQueryProducer- Specified by:
createNativeQueryin interfaceQueryProducerImplementor- Parameters:
sqlString- a native SQL query string- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String)
-
createNativeQuery
public NativeQueryImplementor createNativeQuery(String sqlString, String resultSetMappingName)
Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native (SQL) query using implicit mapping to the specified Java type.- Specified by:
createNativeQueryin interfaceQueryProducer- Specified by:
createNativeQueryin 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:QueryProducerCreate aNativeQueryinstance 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:
createNativeQueryin interfaceQueryProducer- Specified by:
createNativeQueryin 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:QueryProducerCreate aNativeQueryinstance 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:
createNativeQueryin interfaceQueryProducer- Specified by:
createNativeQueryin 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
NativeQueryinstance 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:QueryProducerCreate aNativeQueryinstance for the given native (SQL) query using implicit mapping to the specified Java type.- Specified by:
createNativeQueryin interfaceQueryProducer- Specified by:
createNativeQueryin interfaceQueryProducerImplementor- Parameters:
sqlString- The native (SQL) query stringresultSetMappingName- The explicit result mapping name- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String,Class),SqlResultSetMapping
-
getNamedQuery
public QueryImplementor getNamedQuery(String queryName)
Description copied from interface:QueryProducerCreate aQueryinstance for the named query.- Specified by:
getNamedQueryin interfaceQueryProducer- Specified by:
getNamedQueryin interfaceQueryProducerImplementor- Parameters:
queryName- the name of a pre-defined, named query- Returns:
- The
Queryinstance for manipulation and execution
-
createNamedQuery
public QueryImplementor createNamedQuery(String name)
Description copied from interface:QueryProducerCreate a typedQueryinstance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQueryin interfaceQueryProducer- Specified by:
createNamedQueryin interfaceQueryProducerImplementor- Parameters:
name- the name of a pre-defined, named query- Returns:
- The
Queryinstance for manipulation and execution - See Also:
EntityManager.createNamedQuery(String)
-
createNamedQuery
public <R> QueryImplementor<R> createNamedQuery(String name, Class<R> resultClass)
Description copied from interface:QueryProducerCreate a typedQueryinstance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQueryin interfaceQueryProducer- Specified by:
createNamedQueryin interfaceQueryProducerImplementor- Parameters:
name- the name of a query defined in metadataresultClass- the type of the query result- Returns:
- The
Queryinstance for manipulation and execution - See Also:
EntityManager.createNamedQuery(String,Class)
-
createNamedSelectionQuery
public SelectionQuery<?> createNamedSelectionQuery(String queryName)
Description copied from interface:QueryProducerCreate aSelectionQueryinstance for the namedNamedQuery- Specified by:
createNamedSelectionQueryin interfaceQueryProducer
-
createNamedSelectionQuery
public <R> SelectionQuery<R> createNamedSelectionQuery(String queryName, Class<R> expectedResultType)
Description copied from interface:QueryProducerCreate aSelectionQueryinstance for the namedNamedQuerywith the expected result-type- Specified by:
createNamedSelectionQueryin interfaceQueryProducer
-
doWork
public void doWork(Work work) throws HibernateException
Description copied from interface:SharedSessionContractPerform work using theConnectionunderlying by this session.- Specified by:
doWorkin 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:SharedSessionContractPerform work using theConnectionunderlying by this session, and return a result.- Specified by:
doReturningWorkin 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:QueryProducerGet aNativeQueryinstance for a named native SQL query- Specified by:
getNamedNativeQueryin interfaceQueryProducer- Specified by:
getNamedNativeQueryin interfaceQueryProducerImplementor- Parameters:
queryName- The name of the pre-defined query- Returns:
- The
NativeQueryinstance for manipulation and execution
-
getNamedNativeQuery
public NativeQueryImplementor getNamedNativeQuery(String queryName, String resultSetMapping)
Description copied from interface:QueryProducerGet aNativeQueryinstance for a named native SQL query- Specified by:
getNamedNativeQueryin interfaceQueryProducer- Specified by:
getNamedNativeQueryin interfaceQueryProducerImplementor- Parameters:
queryName- The name of the pre-defined query- Returns:
- The
NativeQueryinstance for manipulation and execution
-
createMutationQuery
public MutationQuery createMutationQuery(String hqlString)
Description copied from interface:QueryProducerCreate a MutationQuery reference for the given HQL insert, update, or delete statement.- Specified by:
createMutationQueryin interfaceQueryProducer- Specified by:
createMutationQueryin interfaceQueryProducerImplementor
-
createNativeMutationQuery
public MutationQuery createNativeMutationQuery(String sqlString)
Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native (SQL) statement- Specified by:
createNativeMutationQueryin interfaceQueryProducer- Specified by:
createNativeMutationQueryin 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:QueryProducerCreate aMutationQueryinstance for the given named insert, update, or delete HQL query. The named query might be defined as HQL) or native-SQL.- Specified by:
createNamedMutationQueryin interfaceQueryProducer- Specified by:
createNamedMutationQueryin interfaceQueryProducerImplementor
-
createMutationQuery
public MutationQuery createMutationQuery(jakarta.persistence.criteria.CriteriaUpdate updateQuery)
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given update criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer- Specified by:
createMutationQueryin interfaceQueryProducerImplementor
-
createMutationQuery
public MutationQuery createMutationQuery(jakarta.persistence.criteria.CriteriaDelete deleteQuery)
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given delete criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer- Specified by:
createMutationQueryin interfaceQueryProducerImplementor
-
createMutationQuery
public MutationQuery createMutationQuery(JpaCriteriaInsertSelect insertSelect)
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given insert-select criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer
-
getNamedProcedureCall
public ProcedureCall getNamedProcedureCall(String name)
Description copied from interface:SharedSessionContractObtain aProcedureCallbased on a named template- Specified by:
getNamedProcedureCallin 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:SharedSessionContractObtain aProcedureCallbased on a named template- Specified by:
createNamedStoredProcedureQueryin 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:SharedSessionContractCreate aProcedureCallto a stored procedure.- Specified by:
createStoredProcedureCallin 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:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureCallin 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:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureCallin 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:SharedSessionContractCreate aProcedureCallto a stored procedure.- Specified by:
createStoredProcedureQueryin 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:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureQueryin 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:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureQueryin 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:SharedSessionContractImplementorThe converter associated to a Session might be lazily initialized: only invoke this getter when there is actual need to use it.- Specified by:
getExceptionConverterin interfaceSharedSessionContractImplementor- Returns:
- the ExceptionConverter for this Session.
-
getJdbcBatchSize
public Integer getJdbcBatchSize()
Description copied from interface:SharedSessionContractGet the session-level JDBC batch size for the current session.- Specified by:
getJdbcBatchSizein interfaceJdbcSessionOwner- Specified by:
getJdbcBatchSizein 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:SharedSessionContractSet the session-level JDBC batch size. Overrides thefactory-levelJDBC batch size defined by the configuration property "hibernate.jdbc.batch_size".- Specified by:
setJdbcBatchSizein 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:SharedSessionContractReturn an instance ofCriteriaBuilder.- Specified by:
getCriteriaBuilderin interfaceSharedSessionContract- Returns:
- an instance of CriteriaBuilder
-
createQuery
public <T> QueryImplementor<T> createQuery(jakarta.persistence.criteria.CriteriaQuery<T> criteriaQuery)
Description copied from interface:QueryProducerCreate aQueryfor the given JPACriteriaQuery- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor
-
createQuery
public QueryImplementor createQuery(jakarta.persistence.criteria.CriteriaUpdate criteriaUpdate)
Description copied from interface:QueryProducerCreate aMutationQueryfor the given JPACriteriaUpdate- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor
-
createQuery
public QueryImplementor createQuery(jakarta.persistence.criteria.CriteriaDelete criteriaDelete)
Description copied from interface:QueryProducerCreate aMutationQueryfor the given JPACriteriaDelete- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor
-
-