Class AbstractSharedSessionContract
- All Implemented Interfaces:
Serializable,AutoCloseable,LobCreationContext,SharedSessionContractImplementor,QueryProducer,QueryProducerImplementor,JdbcSessionOwner,TransactionCoordinatorBuilder.Options,SharedSessionContract,JavaType.CoercionContext,WrapperOptions
- Direct Known Subclasses:
SessionImpl,StatelessSessionImpl
SharedSessionContract and
SharedSessionContractImplementor. Intended for concrete implementations of
Session and StatelessSession.
- See Also:
- Implementation Note:
- A
Sessionor JPAEntityManageris 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
FieldsModifier and TypeFieldDescriptionprotected booleanprotected FastSessionServicesprotected boolean -
Constructor Summary
ConstructorsConstructorDescriptionAbstractSharedSessionContract(SessionFactoryImpl factory, SessionCreationOptions options) -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the currentTransaction, or creates a new transaction if there is no transaction active.protected <T> voidaddResultType(Class<T> resultClass, NativeQueryImplementor<T> query) protected voidaddSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) voidafterTransactionCompletion(boolean successful, boolean delayed) An after-completion callback to the owner.protected voidapplyQuerySettingsAndHints(Query<?> query) protected voidapplyQuerySettingsAndHints(SelectionQuery<?> query) voidA before-completion callback to the owner.Begin a unit of work and return the associatedTransactionobject.protected <T> QueryImplementor<T>buildNamedQuery(String queryName, Class<T> resultType) protected <Q> QbuildNamedQuery(String queryName, Function<NamedSqmQueryMemento, Q> sqlCreator, Function<NamedNativeQueryMemento, Q> nativeCreator) protected static voidcheckMutationQuery(String hqlString, SqmStatement<?> sqmStatement) voidcheckOpen(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 voidprotected static <R> voidcheckResultType(Class<R> expectedResultType, SqmSelectionQueryImpl<R> query) protected static voidcheckSelectionQuery(String hql, HqlInterpretation<?> hqlInterpretation) voidcheckTransactionNeededForUpdateOperation(String exceptionMessage) Check if an activeTransactionis available before performing an update operation against the database.protected voidprotected voidvoidclose()End the session by releasing the JDBC connection and cleaning up.protected <T> QueryImplementor<T>createCriteriaQuery(SqmStatement<T> criteria, Class<T> resultType) <T> RootGraphImplementor<T>createEntityGraph(Class<T> rootType) Create a new mutableEntityGraphwith only a root node.<T> RootGraph<T>createEntityGraph(Class<T> rootType, String graphName) Create a new mutable copy of the namedEntityGraph, or returnnullif there is no graph with the given name.createEntityGraph(String graphName) Create a new mutable copy of the namedEntityGraph, or returnnullif there is no graph with the given name.createMutationQuery(CriteriaDelete deleteQuery) Create aMutationQueryfrom the given delete criteria treecreateMutationQuery(CriteriaUpdate updateQuery) Create aMutationQueryfrom the given update criteria treecreateMutationQuery(String hqlString) Create aMutationQueryreference for the given HQL insert, update, or delete statement.createMutationQuery(JpaCriteriaInsert insertSelect) Create aMutationQueryfrom the given insert criteria treecreateMutationQuery(JpaCriteriaInsertSelect insertSelect) Create aMutationQueryfrom the given insert-select criteria treecreateNamedMutationQuery(String queryName) Create aMutationQueryinstance for the given named insert, update, or delete HQL query.createNamedQuery(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.createNamedSelectionQuery(String queryName) Create aSelectionQueryinstance for the namedNamedQuery.<R> SelectionQuery<R>createNamedSelectionQuery(String queryName, Class<R> expectedResultType) Create aSelectionQueryinstance for the namedNamedQuerywith the given result type.Obtain aProcedureCallbased on a named templatecreateNativeMutationQuery(String sqlString) Create aNativeQueryinstance for the given native SQL statement.createNativeQuery(String sqlString) Create aNativeQueryinstance for the given native SQL query.createNativeQuery(String sqlString, Class resultClass) Create aNativeQueryinstance 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 aNativeQueryinstance for the given native SQL query using an implicit mapping to the specified Java entity type.createNativeQuery(String sqlString, String resultSetMappingName) Create aNativeQueryinstance 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 aNativeQueryinstance 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) createQuery(CriteriaDelete criteriaDelete) Create aMutationQueryfor the given JPACriteriaDelete<T> QueryImplementor<T>createQuery(CriteriaQuery<T> criteriaQuery) Create aQueryfor the given JPACriteriaQuery.createQuery(CriteriaUpdate criteriaUpdate) Create aMutationQueryfor the given JPACriteriaUpdate<R> QueryImplementor<R>createQuery(TypedQueryReference<R> typedQueryReference) Create a typedQueryinstance for the given typed query reference.createQuery(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 and given query result type.<R> SelectionQuery<R>createSelectionQuery(CriteriaQuery<R> criteria) Create aSelectionQueryreference for the givenCriteriaQuery.createSelectionQuery(String hqlString) Create aSelectionQueryreference for the given HQLselectstatement.<R> SelectionQuery<R>createSelectionQuery(String hqlString, Class<R> expectedResultType) Create aSelectionQueryinstance 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) createStoredProcedureCall(String procedureName) Create aProcedureCallto a stored procedure.createStoredProcedureCall(String procedureName, Class<?>... resultClasses) Create aProcedureCallto a stored procedure with the given result set entity mappings.createStoredProcedureCall(String procedureName, String... resultSetMappings) Create aProcedureCallto a stored procedure with the given result set entity mappings.createStoredProcedureQuery(String procedureName) Create aProcedureCallto a stored procedure.createStoredProcedureQuery(String procedureName, Class<?>... resultClasses) Create aProcedureCallto a stored procedure with the given result set entity mappings.createStoredProcedureQuery(String procedureName, String... resultSetMappings) Create aProcedureCallto a stored procedure with the given result set entity mappings.protected voidvoiddisableFilter(String filterName) Disable the named filter for the current session.<T> TdoReturningWork(ReturningWork<T> work) Perform work using theConnectionunderlying by this session, and return a result.voidPerform work using theConnectionunderlying by this session.enableFilter(String filterName) Enable the named filter for this current session.<T> Texecute(LobCreationContext.Callback<T> callback) Execute the given callback, making sure it has access to a viable JDBCConnection.generateEntityKey(Object id, EntityPersister persister) Instantiate anEntityKeywith the given id and for the entity represented by the givenEntityPersister.Get the currentCacheModefor this session.The currentCacheTransactionSynchronizationassociated with this session.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.protected TransactionImplementorgetEnabledFilter(String filterName) Retrieve a currently enabled filter by name.getEntityGraph(String graphName) Retrieve the namedEntityGraphas an immutable graph, or returnnullif there is no graph with the given name.<T> List<EntityGraph<? super T>>getEntityGraphs(Class<T> entityClass) Retrieve all namedEntityGraphs with the given type.Get theSessionEventListenerManagerassociated with this session.Obtain anExceptionConverterfor reporting an error.Obtain the factory which created this session.Get the currentFlushModeTypefor this session.Get the currentFlushModefor this session.Retrieves theInterceptorassociated with this session.Get the session-level JDBC batch size for the current session.Obtain theJdbcCoordinatorfor this session.Obtain theJdbcServicesfor the factory which created this session.The JDBCTimeZoneused when writing a value of typeTimeorTimestampto a JDBCPreparedStatement, or when reading from a JDBCResultSet.Obtain access to theLobCreator.getNamedNativeQuery(String queryName) Get aNativeQueryinstance for a named native SQL querygetNamedNativeQuery(String queryName, String resultSetMapping) Get aNativeQueryinstance for a named native SQL querygetNamedProcedureCall(String name) Obtain aProcedureCallbased on a named templategetNamedQuery(String queryName) Create aQueryinstance for the named query.booleanintThe JDBCtype codeused to bind a null boolean value.protected NamedResultSetMappingMementogetResultSetMappingMemento(String resultSetMappingName) Obtain aUUIDwhich uniquely identifies this session.Obtain a "token" which uniquely identifies this session.Obtain the tenant identifier associated with this session.Obtain the tenant identifier associated with this session.Get theTransactioninstance associated with this session.Obtain the builder for TransactionCoordinator instancesprotected <R> HqlInterpretation<R>interpretHql(String hql, Class<R> resultType) booleanisClosed()Determines whether the session is closed.booleanCheck if the session is currently connected.booleanbooleanCheck if the session is joined to the current transaction.booleanisOpen()Check if the session is still open.booleanDetermines whether the session is open or is waiting for auto-close.booleanDoes this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?voidJoin the currently-active JTA transaction.protected abstract ObjectvoidMarks current transaction, if any, for rollback only.protected voidvoidprepareForQueryExecution(boolean requiresTxn) Prepare for the execution of aQueryorProcedureCallprotected voidprotected voidremoveSharedSessionTransactionObserver(TransactionCoordinator transactionCoordinator) voidsetCacheMode(CacheMode cacheMode) Set the currentCacheModefor this session.protected voidvoidsetCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled) voidsetHibernateFlushMode(FlushMode flushMode) Set the currentFlushModefor this session.voidsetJdbcBatchSize(Integer jdbcBatchSize) Set the session-level JDBC batch size.voidsetNativeJdbcParametersIgnored(boolean nativeJdbcParametersIgnored) protected final voidsetUpMultitenancy(SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) booleanIndicates whether an active transaction should be automatically joined.protected booleanshouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared) voidCallback 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 TransactionbooleanDetermines 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, waitMethods inherited from interface org.hibernate.resource.jdbc.spi.JdbcSessionOwner
afterTransactionBegin, flushBeforeTransactionCompletion, getSqlExceptionHelperMethods inherited from interface org.hibernate.engine.jdbc.LobCreationContext
fromContextMethods inherited from interface org.hibernate.engine.spi.SharedSessionContractImplementor
afterOperation, afterScrollOperation, asEventSource, asSessionImplementor, asStatelessSession, autoFlushIfRequired, autoFlushIfRequired, autoPreFlush, bestGuessEntityName, bestGuessEntityName, checkOpen, flush, getContextEntityIdentifier, getEntityPersister, getEntityUsingInterceptor, getLoadQueryInfluencers, getPersistenceContext, getPersistenceContextInternal, getSession, getSessionFactory, getTypeConfiguration, guessEntityName, immediateLoad, initializeCollection, instantiate, instantiate, internalLoad, isAutoCloseSessionEnabled, isDefaultReadOnly, isEventSource, isSessionImplementor, isStatelessSession, setAutoClear, shouldAutoCloseMethods inherited from interface org.hibernate.type.descriptor.WrapperOptions
getDialect
-
Field Details
-
fastSessionServices
-
closed
protected boolean closed -
waitingForAutoClose
protected boolean waitingForAutoClose
-
-
Constructor Details
-
AbstractSharedSessionContract
-
-
Method Details
-
setUpMultitenancy
protected final void setUpMultitenancy(SessionFactoryImplementor factory, LoadQueryInfluencers loadQueryInfluencers) -
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:
- the session-level JDBC batch size is set, or the factory-level setting otherwise
- See Also:
-
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
Description copied from interface:SharedSessionContractImplementorObtain the factory which created this session.- Specified by:
getFactoryin interfaceQueryProducerImplementor- Specified by:
getFactoryin interfaceSharedSessionContract- Specified by:
getFactoryin interfaceSharedSessionContractImplementor
-
getInterceptor
Description copied from interface:SharedSessionContractImplementorRetrieves theInterceptorassociated with this session.- Specified by:
getInterceptorin interfaceSharedSessionContractImplementor
-
getJdbcCoordinator
Description copied from interface:SharedSessionContractImplementorObtain theJdbcCoordinatorfor this session.- Specified by:
getJdbcCoordinatorin interfaceSharedSessionContractImplementor
-
getTransactionCoordinator
Description copied from interface:JdbcSessionOwnerObtain the builder for TransactionCoordinator instances- Specified by:
getTransactionCoordinatorin interfaceJdbcSessionOwner- Returns:
- The TransactionCoordinatorBuilder
-
getJdbcSessionContext
- Specified by:
getJdbcSessionContextin interfaceJdbcSessionOwner
-
getEntityNameResolver
-
getEventListenerManager
Description copied from interface:SharedSessionContractImplementorGet theSessionEventListenerManagerassociated with this session.- Specified by:
getEventListenerManagerin interfaceSharedSessionContractImplementor
-
getSessionIdentifier
Description copied from interface:SharedSessionContractImplementorObtain aUUIDwhich uniquely identifies this session.The UUID is useful mainly for logging.
- Specified by:
getSessionIdentifierin interfaceSharedSessionContractImplementor
-
getSessionToken
Description copied from interface:SharedSessionContractImplementorObtain a "token" which uniquely identifies this session.- Specified by:
getSessionTokenin interfaceSharedSessionContractImplementor
-
getTenantIdentifier
Description copied from interface:SharedSessionContractObtain the tenant identifier associated with this session.- Specified by:
getTenantIdentifierin interfaceSharedSessionContract- Returns:
- The tenant identifier associated with this session, or
null
-
getTenantIdentifierValue
Description copied from interface:SharedSessionContractObtain the tenant identifier associated with this session.- Specified by:
getTenantIdentifierValuein interfaceSharedSessionContract- Returns:
- The tenant identifier associated with this session, or
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:SharedSessionContractImplementorDetermines whether the session is closed.- 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 interfaceSharedSessionContract
-
setClosed
protected void setClosed() -
shouldCloseJdbcCoordinatorOnClose
protected boolean shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordinatorShared) -
cleanupOnClose
protected void cleanupOnClose() -
isOpenOrWaitingForAutoClose
public boolean isOpenOrWaitingForAutoClose()Description copied from interface:SharedSessionContractImplementorDetermines 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:SharedSessionContractImplementorCheck 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:
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 any, for rollback only.- Specified by:
markForRollbackOnlyin interfaceSharedSessionContractImplementor
-
isTransactionInProgress
public boolean isTransactionInProgress()Description copied from interface:SharedSessionContractImplementorDoes this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?- Specified by:
isTransactionInProgressin interfaceSharedSessionContractImplementor
-
checkTransactionNeededForUpdateOperation
Description copied from interface:SharedSessionContractImplementorCheck if an activeTransactionis available before performing an update operation against the database.If an active transaction is necessary, but no transaction is active, a
TransactionRequiredExceptionis raised.- Specified by:
checkTransactionNeededForUpdateOperationin interfaceSharedSessionContractImplementor- Parameters:
exceptionMessage- the message to use for theTransactionRequiredException
-
getTransaction
Description copied from interface:SharedSessionContractGet theTransactioninstance associated with this session.- Specified by:
getTransactionin interfaceSharedSessionContract- Returns:
- a Transaction instance
- Throws:
HibernateException- See Also:
-
accessTransaction
Description copied from interface:SharedSessionContractImplementorRetrieves the currentTransaction, or creates a new transaction if there is no transaction active.This method 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
Description copied from interface:SharedSessionContractImplementorThe currentCacheTransactionSynchronizationassociated with this session. This may benullif the session is not currently associated with an active transaction.- Specified by:
getCacheTransactionSynchronizationin interfaceSharedSessionContractImplementor
-
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:
-
checkTransactionSynchStatus
protected void checkTransactionSynchStatus() -
pulseTransactionCoordinator
protected void pulseTransactionCoordinator() -
joinTransaction
public void joinTransaction()Description copied from interface:SharedSessionContractJoin the currently-active JTA transaction.- Specified by:
joinTransactionin interfaceSharedSessionContract- See Also:
-
isJoinedToTransaction
public boolean isJoinedToTransaction()Description copied from interface:SharedSessionContractCheck if the session is joined to the current transaction.- Specified by:
isJoinedToTransactionin interfaceSharedSessionContract- See Also:
-
delayedAfterCompletion
protected void delayedAfterCompletion() -
getCurrentTransaction
-
isConnected
public boolean isConnected()Description copied from interface:SharedSessionContractCheck if the session is currently connected.- Specified by:
isConnectedin interfaceSharedSessionContract- Returns:
- boolean
-
getJdbcConnectionAccess
- Specified by:
getJdbcConnectionAccessin interfaceJdbcSessionOwner
-
generateEntityKey
Description copied from interface:SharedSessionContractImplementorInstantiate anEntityKeywith the given id and for the entity represented by the givenEntityPersister.- Specified by:
generateEntityKeyin interfaceSharedSessionContractImplementor- Parameters:
id- The entity idpersister- The entity persister- Returns:
- The entity key
-
useStreamForLobBinding
public boolean useStreamForLobBinding()Description copied from interface:WrapperOptionsDetermines whether streams should be used for binding LOB values.- Specified by:
useStreamForLobBindingin interfaceWrapperOptions- Returns:
true/false- See Also:
-
getPreferredSqlTypeCodeForBoolean
public int getPreferredSqlTypeCodeForBoolean()Description copied from interface:WrapperOptionsThe JDBCtype codeused to bind a null boolean value.- Specified by:
getPreferredSqlTypeCodeForBooleanin interfaceWrapperOptions- See Also:
-
getLobCreator
Description copied from interface:WrapperOptionsObtain access to theLobCreator.- Specified by:
getLobCreatorin interfaceWrapperOptions- Returns:
- The LOB creator
- See Also:
-
execute
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
Description copied from interface:WrapperOptionsThe JDBCTimeZoneused when writing a value of typeTimeorTimestampto 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
TimeZonecan differ from the default JVM TimeZone given byTimeZone.getDefault().- Specified by:
getJdbcTimeZonein interfaceWrapperOptions- Returns:
- the JDBC
TimeZone, or null if no JDBC timezone was explicitly set - See Also:
- When
-
getJdbcServices
Description copied from interface:SharedSessionContractImplementorObtain theJdbcServicesfor the factory which created this session.- Specified by:
getJdbcServicesin interfaceSharedSessionContractImplementor
-
getFlushMode
Description copied from interface:SharedSessionContractImplementorGet the currentFlushModeTypefor 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
FlushModeTyperather than Hibernate'sFlushMode. For the former behavior, useSharedSessionContractImplementor.getHibernateFlushMode()instead.- Specified by:
getFlushModein interfaceSharedSessionContractImplementor- Returns:
- The
FlushModeTypein effect for this Session.
-
setHibernateFlushMode
Description copied from interface:SharedSessionContractImplementorSet the currentFlushModefor 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.MANUALat the start of the session (in order skip some work and gain some extra performance).- Specified by:
setHibernateFlushModein interfaceSharedSessionContractImplementor- Parameters:
flushMode- the new flush mode
-
getHibernateFlushMode
Description copied from interface:SharedSessionContractImplementorGet the currentFlushModefor this session.- Specified by:
getHibernateFlushModein interfaceQueryProducerImplementor- Specified by:
getHibernateFlushModein interfaceSharedSessionContractImplementor- Returns:
- The flush mode
-
getCacheMode
Description copied from interface:SharedSessionContractImplementorGet the currentCacheModefor this session.- Specified by:
getCacheModein interfaceQueryProducerImplementor- Specified by:
getCacheModein interfaceSharedSessionContractImplementor
-
setCacheMode
Description copied from interface:SharedSessionContractImplementorSet the currentCacheModefor this session.- Specified by:
setCacheModein interfaceSharedSessionContractImplementor
-
setCriteriaCopyTreeEnabled
public void setCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled) - Specified by:
setCriteriaCopyTreeEnabledin interfaceSharedSessionContractImplementor
-
isCriteriaCopyTreeEnabled
public boolean isCriteriaCopyTreeEnabled()- Specified by:
isCriteriaCopyTreeEnabledin interfaceSharedSessionContractImplementor
-
getNativeJdbcParametersIgnored
public boolean getNativeJdbcParametersIgnored()- Specified by:
getNativeJdbcParametersIgnoredin interfaceSharedSessionContractImplementor
-
setNativeJdbcParametersIgnored
public void setNativeJdbcParametersIgnored(boolean nativeJdbcParametersIgnored) - Specified by:
setNativeJdbcParametersIgnoredin interfaceSharedSessionContractImplementor
-
createQuery
Description copied from interface:QueryProducerCreate aQueryinstance for the given HQL query, or HQL insert, update, or delete statement.If a query has no explicit
selectlist, the select list is inferred:- if there is exactly one root entity in the
fromclause, then that root entity is the only element of the select list, or - otherwise, if there are multiple root entities in the
fromclause, then the select list contains every root entity and every non-fetchjoined entity.
- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor- Parameters:
queryString- The HQL query- Returns:
- The
Queryinstance for manipulation and execution - See Also:
- if there is exactly one root entity in the
-
createSelectionQuery
Description copied from interface:QueryProducerCreate aSelectionQueryreference for the given HQLselectstatement.If the statement has no explicit
selectlist, the select list is inferred:- if there is exactly one root entity in the
fromclause, then that root entity is the only element of the select list, or - otherwise, if there are multiple root entities in the
fromclause, then the select list contains every root entity and every non-fetchjoined entity.
- Specified by:
createSelectionQueryin interfaceQueryProducer
- if there is exactly one root entity in the
-
interpretHql
-
checkSelectionQuery
-
checkResultType
protected static <R> void checkResultType(Class<R> expectedResultType, SqmSelectionQueryImpl<R> query) -
createSelectionQuery
Description copied from interface:QueryProducerCreate aSelectionQueryinstance for the given HQL query string and given query result type.- If the query has a single item in the
selectlist, 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
selectlist, 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
fromclause, 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-
fetchjoined entity, and each query result will be packaged into an instance of the result type, just as specified above.
The returned
Querymay be executed by callingQuery.getResultList()orQuery.getSingleResult().- Specified by:
createSelectionQueryin interfaceQueryProducer- Parameters:
hqlString- The HQL query as a stringexpectedResultType- TheClassobject representing the query result type- See Also:
- If the query has a single item in the
-
createSelectionQuery
Description copied from interface:QueryProducerCreate aSelectionQueryreference for the givenCriteriaQuery.- Specified by:
createSelectionQueryin interfaceQueryProducer- See Also:
-
createQuery
Description copied from interface:QueryProducerCreate a typedQueryinstance for the given HQL query string and given query result type.- If the query has a single item in the
selectlist, 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
selectlist, 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
fromclause, 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-
fetchjoined entity, and each query result will be packaged into an instance of the result type, just as specified above.
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
Queryinstance for manipulation and execution - See Also:
- If the query has a single item in the
-
createQuery
Description copied from interface:QueryProducerCreate a typedQueryinstance for the given typed query reference.- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor- Parameters:
typedQueryReference- the type query reference- Returns:
- The
Queryinstance for execution - See Also:
-
createNativeQuery
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:
-
createNativeQuery
Description copied from interface:QueryProducerCreate aNativeQueryinstance 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
SqlResultSetMappingannotation.- 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:
-
getResultSetMappingMemento
-
createNativeQuery
Description copied from interface:QueryProducerCreate aNativeQueryinstance 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 whoseJdbcTypeis 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:
createNativeQueryin interfaceQueryProducer- Specified by:
createNativeQueryin interfaceQueryProducerImplementor- Parameters:
sqlString- The native (SQL) query stringresultClass- The Java type to map results to- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
- If the given class is an entity class, this method is equivalent
to
-
addResultType
-
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 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:
createNativeQueryin interfaceQueryProducer- Specified by:
createNativeQueryin 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
NativeQueryinstance for manipulation and execution - See Also:
-
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 an explicit mapping to the specified Java type.The given result set mapping name must identify a mapping defined by a
SqlResultSetMappingannotation.- 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:
-
getNamedQuery
Description copied from interface:QueryProducerCreate aQueryinstance for the named query.- Specified by:
getNamedQueryin interfaceQueryProducer- Specified by:
getNamedQueryin interfaceQueryProducerImplementor- Parameters:
queryName- the name of a predefined named query- Returns:
- The
Queryinstance for manipulation and execution
-
createNamedQuery
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 predefined named query- Returns:
- The
Queryinstance for manipulation and execution - See Also:
-
createNamedQuery
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:
-
createNamedSelectionQuery
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 given result type.- Specified by:
createNamedSelectionQueryin interfaceQueryProducer
-
doWork
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
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
-
applyQuerySettingsAndHints
-
applyQuerySettingsAndHints
-
buildNamedQuery
protected <Q> Q buildNamedQuery(String queryName, Function<NamedSqmQueryMemento, Q> sqlCreator, Function<NamedNativeQueryMemento, Q> nativeCreator) -
buildNamedQuery
-
createNativeQueryImplementor
protected <T> NativeQueryImplementor<T> createNativeQueryImplementor(Class<T> resultType, NamedNativeQueryMemento memento) -
createSqmQueryImplementor
protected <T> SqmQueryImplementor<T> createSqmQueryImplementor(Class<T> resultType, NamedSqmQueryMemento memento) -
getNamedNativeQuery
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 predefined query- Returns:
- The
NativeQueryinstance for manipulation and execution
-
getNamedNativeQuery
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 predefined query- Returns:
- The
NativeQueryinstance for manipulation and execution
-
createMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryreference for the given HQL insert, update, or delete statement.- Specified by:
createMutationQueryin interfaceQueryProducer- Specified by:
createMutationQueryin interfaceQueryProducerImplementor
-
checkMutationQuery
-
createNativeMutationQuery
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
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
-
createNativeQueryImplementor
protected NativeQueryImplementor<?> createNativeQueryImplementor(String queryName, NamedNativeQueryMemento memento) -
createSqmQueryImplementor
protected SqmQueryImplementor<?> createSqmQueryImplementor(String queryName, NamedSqmQueryMemento memento) -
createMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given update criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer- Specified by:
createMutationQueryin interfaceQueryProducerImplementor
-
createMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given delete criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer- Specified by:
createMutationQueryin interfaceQueryProducerImplementor
-
createMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given insert-select criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer
-
createMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given insert criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer
-
getNamedProcedureCall
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:
-
createNamedStoredProcedureQuery
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:
-
createStoredProcedureCall
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
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
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
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
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
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.
-
load
-
getExceptionConverter
Description copied from interface:SharedSessionContractImplementorObtain anExceptionConverterfor 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:
getExceptionConverterin interfaceSharedSessionContractImplementor- Returns:
- the ExceptionConverter for this Session.
-
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:
-
getEventManager
- Specified by:
getEventManagerin interfaceJdbcSessionOwner
-
setJdbcBatchSize
Description copied from interface:SharedSessionContractSet the session-level JDBC batch size. Override the factory-level JDBC batch size controlled by the configuration property "hibernate.jdbc.batch_size".- Specified by:
setJdbcBatchSizein interfaceSharedSessionContract- Parameters:
jdbcBatchSize- the new session-level JDBC batch size- See Also:
-
getCriteriaBuilder
Description copied from interface:SharedSessionContract- Specified by:
getCriteriaBuilderin interfaceSharedSessionContract- Returns:
- an instance of
HibernateCriteriaBuilder - See Also:
-
createQuery
Description copied from interface:QueryProducerCreate aQueryfor the given JPACriteriaQuery.- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor
-
createQuery
Description copied from interface:QueryProducerCreate aMutationQueryfor the given JPACriteriaUpdate- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor
-
createQuery
Description copied from interface:QueryProducerCreate aMutationQueryfor the given JPACriteriaDelete- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor
-
createCriteriaQuery
protected <T> QueryImplementor<T> createCriteriaQuery(SqmStatement<T> criteria, Class<T> resultType) -
createEntityGraph
Description copied from interface:SharedSessionContractCreate a new mutableEntityGraphwith only a root node.- Specified by:
createEntityGraphin interfaceSharedSessionContract- Parameters:
rootType- the root entity class of the graph
-
createEntityGraph
Description copied from interface:SharedSessionContractCreate a new mutable copy of the namedEntityGraph, or returnnullif there is no graph with the given name.- Specified by:
createEntityGraphin interfaceSharedSessionContract- Parameters:
rootType- the root entity class of the graphgraphName- the name of the graph- See Also:
-
createEntityGraph
Description copied from interface:SharedSessionContractCreate a new mutable copy of the namedEntityGraph, or returnnullif there is no graph with the given name.- Specified by:
createEntityGraphin interfaceSharedSessionContract- Parameters:
graphName- the name of the graph- See Also:
-
getEntityGraph
Description copied from interface:SharedSessionContractRetrieve the namedEntityGraphas an immutable graph, or returnnullif there is no graph with the given name.- Specified by:
getEntityGraphin interfaceSharedSessionContract- Parameters:
graphName- the name of the graph- See Also:
-
getEntityGraphs
Description copied from interface:SharedSessionContractRetrieve all namedEntityGraphs with the given type.- Specified by:
getEntityGraphsin interfaceSharedSessionContract- See Also:
-
getEnabledFilter
Description copied from interface:SharedSessionContractRetrieve a currently enabled filter by name.- Specified by:
getEnabledFilterin interfaceSharedSessionContract- Parameters:
filterName- the name of the filter to be retrieved.- Returns:
- the
Filterinstance representing the enabled filter.
-
enableFilter
Description copied from interface:SharedSessionContractEnable the named filter for this current session.The returned
Filterobject must be used to bind arguments to parameters of the filter, and every parameter must be set before any other operation of this session is called.- Specified by:
enableFilterin interfaceSharedSessionContract- Parameters:
filterName- the name of the filter to be enabled.- Returns:
- the
Filterinstance representing the enabled filter. - See Also:
-
disableFilter
Description copied from interface:SharedSessionContractDisable the named filter for the current session.- Specified by:
disableFilterin interfaceSharedSessionContract- Parameters:
filterName- the name of the filter to be disabled.
-