Class SessionDelegatorBaseImpl
- java.lang.Object
-
- org.hibernate.engine.spi.SessionDelegatorBaseImpl
-
- All Implemented Interfaces:
jakarta.persistence.EntityManager,Closeable,Serializable,AutoCloseable,LobCreationContext,SessionImplementor,SharedSessionContractImplementor,QueryProducer,QueryProducerImplementor,JdbcSessionOwner,TransactionCoordinatorBuilder.Options,Session,SharedSessionContract,JavaType.CoercionContext,WrapperOptions
- Direct Known Subclasses:
AbstractDelegateSessionImplementor
public class SessionDelegatorBaseImpl extends Object implements SessionImplementor
This class is meant to be extended. Wraps and delegates all methods to aSessionImplementorand aSession. This is useful for custom implementations of this API so that only some methods need to be overridden (Used by Hibernate Search).- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hibernate.engine.jdbc.LobCreationContext
LobCreationContext.Callback<T>
-
Nested classes/interfaces inherited from interface org.hibernate.Session
Session.LockRequest
-
-
Field Summary
Fields Modifier and Type Field Description protected SessionImplementordelegate
-
Constructor Summary
Constructors Constructor Description SessionDelegatorBaseImpl(SessionImplementor delegate)
-
Method Summary
All Methods Instance 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.voidaddEventListeners(SessionEventListener... listeners)Add one or more listeners to the SessionvoidafterOperation(boolean success)Check if there is a Hibernate or JTA transaction in progress and, if there is not, flush if necessary, make sure the connection has been committed (if it is not in autocommit mode) and run the after completion processingvoidafterScrollOperation()voidafterTransactionBegin()A after-begin callback from the coordinator to its owner.voidafterTransactionCompletion(boolean successful, boolean delayed)An after-completion callback to the owner.booleanautoFlushIfRequired(Set<String> querySpaces)detect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flushvoidbeforeTransactionCompletion()A before-completion callback to the owner.TransactionbeginTransaction()Begin a unit of work and return the associatedTransactionobject.StringbestGuessEntityName(Object object)The best guess entity name for an entity not in an associationSession.LockRequestbuildLockRequest(LockOptions lockOptions)Build a newlock requestthat specifies: theLockModeto use, the pessimistic lock timeout, and the scope of the lock.<T> IdentifierLoadAccess<T>byId(Class<T> entityClass)Create anIdentifierLoadAccessinstance to retrieve the specified entity by primary key.<T> IdentifierLoadAccess<T>byId(String entityName)Create anIdentifierLoadAccessinstance to retrieve the specified entity type by primary key.<T> MultiIdentifierLoadAccess<T>byMultipleIds(Class<T> entityClass)Create aMultiIdentifierLoadAccessinstance to retrieve multiple entities at once as specified by primary key values.<T> MultiIdentifierLoadAccess<T>byMultipleIds(String entityName)Create aMultiIdentifierLoadAccessinstance to retrieve multiple entities at once as specified by primary key values.<T> NaturalIdMultiLoadAccess<T>byMultipleNaturalId(Class<T> entityClass)Access to load multiple entities bynatural id.<T> NaturalIdMultiLoadAccess<T>byMultipleNaturalId(String entityName)Access to load multiple entities bynatural id.<T> NaturalIdLoadAccess<T>byNaturalId(Class<T> entityClass)Create aNaturalIdLoadAccessinstance to retrieve the specified entity by its natural id.<T> NaturalIdLoadAccess<T>byNaturalId(String entityName)Create aNaturalIdLoadAccessinstance to retrieve the specified entity by its natural id.<T> SimpleNaturalIdLoadAccess<T>bySimpleNaturalId(Class<T> entityClass)Create aSimpleNaturalIdLoadAccessinstance to retrieve the specified entity by its simple (single attribute)natural id.<T> SimpleNaturalIdLoadAccess<T>bySimpleNaturalId(String entityName)Create aSimpleNaturalIdLoadAccessinstance to retrieve the specified entity by itsnatural id.voidcancelQuery()Cancel the execution of the current query.voidcheckOpen()Performs a check whether the Session is open, and if not: marks current transaction (if one) for rollback only throws an IllegalStateException (JPA defines the exception type)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)voidcheckTransactionNeededForUpdateOperation(String exceptionMessage)Check if an active Transaction is necessary for the update operation to be executed.voidclear()Completely clear the session.voidclose()End the session by releasing the JDBC connection and cleaning up.booleancontains(Object object)booleancontains(String entityName, Object object)Determine if the given entity is associated with this session.<T> RootGraphImplementor<T>createEntityGraph(Class<T> rootType)RootGraphImplementor<?>createEntityGraph(String graphName)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 statementString)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 name)Create aMutationQueryinstance for the given named insert, update, or delete HQL query.QueryImplementorcreateNamedQuery(String name)Create a typedQueryinstance for the given named query.<T> QueryImplementor<T>createNamedQuery(String name, Class<T> resultClass)Create a typedQueryinstance for the given named query.SelectionQuery<?>createNamedSelectionQuery(String name)Create aSelectionQueryinstance for the namedNamedQuery<R> SelectionQuery<R>createNamedSelectionQuery(String name, Class<R> resultType)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) statementNativeQueryImplementorcreateNativeQuery(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 deleteQuery)Create aQueryfor the given JPACriteriaDelete<T> QueryImplementor<T>createQuery(jakarta.persistence.criteria.CriteriaQuery<T> criteriaQuery)Create aQueryfor the given JPACriteriaQueryQueryImplementorcreateQuery(jakarta.persistence.criteria.CriteriaUpdate updateQuery)Create aQueryfor 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> resultType)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> resultType)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 SessionImplementordelegate()Returns the underlying delegate.voiddelete(Object object)Remove a persistent instance from the datastore.voiddelete(String entityName, Object object)Remove a persistent instance from the datastore.voiddelete(String entityName, Object child, boolean isCascadeDeleteEnabled, DeleteContext transientEntities)voiddetach(Object entity)Remove this instance from the session cache.voiddisableFetchProfile(String name)Disable a particular fetch profile on this session.voiddisableFilter(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.voiddoWork(Work work)Perform work using theConnectionunderlying by this session.voidenableFetchProfile(String name)Enable a particular fetch profile on this session.FilterenableFilter(String filterName)Enable the named filter for this current session.voidevict(Object object)Remove this instance from the session cache.<T> Texecute(LobCreationContext.Callback<T> callback)Execute the given callback, making sure it has access to a viable JDBCConnection.<T> Tfind(Class<T> entityClass, Object primaryKey)<T> Tfind(Class<T> entityClass, Object primaryKey, jakarta.persistence.LockModeType lockMode)<T> Tfind(Class<T> entityClass, Object primaryKey, jakarta.persistence.LockModeType lockMode, Map<String,Object> properties)<T> Tfind(Class<T> entityClass, Object primaryKey, Map<String,Object> properties)voidflush()Force this session to flush.voidflushBeforeTransactionCompletion()voidforceFlush(EntityEntry e)EntityKeygenerateEntityKey(Object id, EntityPersister persister)Hide the changing requirements of entity key creation<T> Tget(Class<T> theClass, Object id)Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.<T> Tget(Class<T> theClass, Object id, LockMode lockMode)Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.<T> Tget(Class<T> theClass, Object id, LockOptions lockOptions)Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.Objectget(String entityName, Object id)Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance.Objectget(String entityName, Object id, LockMode lockMode)Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.Objectget(String entityName, Object id, LockOptions lockOptions)Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.ActionQueuegetActionQueue()CacheModegetCacheMode()Get the currentcache modefor this session.CacheTransactionSynchronizationgetCacheTransactionSynchronization()The current CacheTransactionContext associated with the Session.ObjectgetContextEntityIdentifier(Object object)Return the identifier of the persistent object, or null if not associated with the sessionHibernateCriteriaBuildergetCriteriaBuilder()Return an instance ofCriteriaBuilder.LockModegetCurrentLockMode(Object object)Determine the currentLockModeof the given managed instance associated with this session.ObjectgetDelegate()This is an implementation of EntityManager#getDelegate().FiltergetEnabledFilter(String filterName)Retrieve a currently enabled filter by name.RootGraphImplementor<?>getEntityGraph(String graphName)<T> List<jakarta.persistence.EntityGraph<? super T>>getEntityGraphs(Class<T> entityClass)jakarta.persistence.EntityManagerFactorygetEntityManagerFactory()StringgetEntityName(Object object)Return the entity name for a persistent entity.EntityPersistergetEntityPersister(String entityName, Object object)Get theEntityPersisterfor any instanceObjectgetEntityUsingInterceptor(EntityKey key)Get the entity instance associated with the givenKey, calling the Interceptor if necessarySessionEventListenerManagergetEventListenerManager()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 currentJPA flush modefor this session.FlushModegetHibernateFlushMode()Get the currentflush modefor this session.ObjectgetIdentifier(Object object)Return the identifier value of the given entity associated with 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.LoadQueryInfluencersgetLoadQueryInfluencers()Get the load query influencers associated with this session.LobCreatorgetLobCreator()Obtain access to theLobCreatorLobHelpergetLobHelper()Retrieve this session's helper/delegate for creating LOB instances.jakarta.persistence.LockModeTypegetLockMode(Object entity)jakarta.persistence.metamodel.MetamodelgetMetamodel()NativeQueryImplementorgetNamedNativeQuery(String name)Get aNativeQueryinstance for a named native SQL queryNativeQueryImplementorgetNamedNativeQuery(String name, String resultSetMapping)Get aNativeQueryinstance for a named native SQL queryProcedureCallgetNamedProcedureCall(String name)Obtain aProcedureCallbased on a named templateQueryImplementorgetNamedQuery(String name)Create aQueryinstance for the named query.PersistenceContextgetPersistenceContext()Get the persistence context for this session.PersistenceContextgetPersistenceContextInternal()This is similar toSharedSessionContractImplementor.getPersistenceContext(), with two main differences: a) this version performs better as it allows for inlining and probably better prediction b) see SessionImplSharedSessionContractImplementor.getPersistenceContext(): it does some checks on the current state of the Session.intgetPreferredSqlTypeCodeForBoolean()Get the JDBCtype codeused to bind a null boolean valueMap<String,Object>getProperties()<T> TgetReference(Class<T> entityClass, Object id)Return a reference to the persistent instance with the given class and identifier, making the assumption that the instance is still persistent in the database.ObjectgetReference(String entityName, Object id)Return a reference to the persistent instance of the given named entity with the given identifier, making the assumption that the instance is still persistent in the database.<T> TgetReference(T object)Return a reference to the persistent instance with the same identity as the given instance, which might be detached, making the assumption that the instance is still persistent in the database.SessionImplementorgetSession()Access to the current SessionSessionFactoryImplementorgetSessionFactory()Get the session factory which created this session.UUIDgetSessionIdentifier()A UUID associated with each Session.SessionStatisticsgetStatistics()Get the statistics for this session.StringgetTenantIdentifier()Obtain the tenant identifier associated with this session.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.StringguessEntityName(Object entity)The guessed entity name for an entity not in an associationObjectimmediateLoad(String entityName, Object id)Load an instance immediately.voidinitializeCollection(PersistentCollection<?> collection, boolean writing)Initialize the collection (if not already initialized)Objectinstantiate(String entityName, Object id)Instantiate the entity class, initializing with the given identifierObjectinstantiate(EntityPersister persister, Object id)Instantiate the entity class of an EntityPersister, initializing with the given identifier.ObjectinternalLoad(String entityName, Object id, boolean eager, boolean nullable)Load an instance without checking if it was deleted.booleanisAutoCloseSessionEnabled()booleanisClosed()Checks whether the session is closed.booleanisConnected()Check if the session is currently connected.booleanisCriteriaCopyTreeEnabled()booleanisDefaultReadOnly()Will entities and proxies that are loaded into this session be made read-only by default?booleanisDirty()Does this session contain any changes which must be synchronized with the database? In other words, would any DML operations be executed if we flushed this session?booleanisEventSource()booleanisFetchProfileEnabled(String name)Is a particular fetch profile enabled on this session?booleanisJoinedToTransaction()booleanisOpen()Check if the session is still open.booleanisOpenOrWaitingForAutoClose()Checks whether the session is open or is waiting for auto-closebooleanisReadOnly(Object entityOrProxy)Is the specified entity or proxy read-only?booleanisTransactionInProgress()Does thisSessionhave an active Hibernate transaction or is there a JTA transaction in progress?voidjoinTransaction()<T> Tload(Class<T> theClass, Object id)Return the persistent instance of the given entity class with the given identifier, making the assumption that the instance exists in the database.<T> Tload(Class<T> theClass, Object id, LockMode lockMode)Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.<T> Tload(Class<T> theClass, Object id, LockOptions lockOptions)Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.voidload(Object object, Object id)Read the persistent state associated with the given identifier into the given transient instance.Objectload(String entityName, Object id)Return the persistent instance of the given entity class with the given identifier, making the assumption that the instance exists in the database.Objectload(String entityName, Object id, LockMode lockMode)Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.Objectload(String entityName, Object id, LockOptions lockOptions)Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.voidlock(Object entity, jakarta.persistence.LockModeType lockMode)voidlock(Object entity, jakarta.persistence.LockModeType lockMode, Map<String,Object> properties)voidlock(Object object, LockMode lockMode)Obtain the specified lock level on the given managed instance association with this session.voidlock(String entityName, Object object, LockMode lockMode)Obtain the specified lock level on the given managed instance association with this session.voidmarkForRollbackOnly()Marks current transaction (if one) for rollback onlyvoidmerge(String entityName, Object object, MergeContext copiedAlready)<T> Tmerge(String entityName, T object)Copy the state of the given object onto the persistent object with the same identifier.<T> Tmerge(T object)Copy the state of the given object onto the persistent object with the same identifier.voidpersist(Object object)Make a transient instance persistent and mark it for later insertion in the database.voidpersist(String entityName, Object object)Make a transient instance persistent and mark it for later insertion in the database.voidpersist(String entityName, Object object, PersistContext createdAlready)voidpersistOnFlush(String entityName, Object object, PersistContext copiedAlready)voidprepareForQueryExecution(boolean requiresTxn)Prepare for the execution of aQueryorProcedureCallvoidrefresh(Object object)Reread the state of the given managed instance associated with this session from the underlying database.voidrefresh(Object entity, jakarta.persistence.LockModeType lockMode)voidrefresh(Object entity, jakarta.persistence.LockModeType lockMode, Map<String,Object> properties)voidrefresh(Object entity, Map<String,Object> properties)voidrefresh(Object object, LockMode lockMode)Reread the state of the given managed instance from the underlying database, obtaining the givenLockMode.voidrefresh(Object object, LockOptions lockOptions)Reread the state of the given managed instance from the underlying database, obtaining the givenLockMode.voidrefresh(String entityName, Object object)Reread the state of the given managed instance associated with this session from the underlying database.voidrefresh(String entityName, Object object, RefreshContext refreshedAlready)voidrefresh(String entityName, Object object, LockOptions lockOptions)Reread the state of the given managed instance from the underlying database, obtaining the givenLockMode.voidremove(Object entity)Mark a persistence instance associated with this session for removal from the underlying database.voidremoveOrphanBeforeUpdates(String entityName, Object child)voidreplicate(Object object, ReplicationMode replicationMode)Persist the state of the given detached instance, reusing the current identifier value.voidreplicate(String entityName, Object object, ReplicationMode replicationMode)Persist the state of the given detached instance, reusing the current identifier value.Objectsave(Object object)Persist the given transient instance, first assigning a generated identifier.Objectsave(String entityName, Object object)Persist the given transient instance, first assigning a generated identifier.voidsaveOrUpdate(Object object)EitherSession.save(Object)orSession.update(Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking).voidsaveOrUpdate(String entityName, Object object)EitherSession.save(String, Object)orSession.update(String, Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking).SharedSessionBuildersessionWithOptions()Obtain aSessionbuilder with the ability to copy certain information from this session.voidsetAutoClear(boolean enabled)Enable/disable automatic cache clearing from after transaction completion (for EJB3)voidsetCacheMode(CacheMode cm)Set the currentcache modefor this session.voidsetCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled)voidsetDefaultReadOnly(boolean readOnly)Change the default for entities and proxies loaded into this session from modifiable to read-only mode, or from modifiable to read-only mode.voidsetFlushMode(jakarta.persistence.FlushModeType flushModeType)Set the currentJPA flush modefor this session.voidsetHibernateFlushMode(FlushMode flushMode)Set the currentflush modefor this session.voidsetJdbcBatchSize(Integer jdbcBatchSize)Set the session-level JDBC batch size.voidsetProperty(String propertyName, Object value)voidsetReadOnly(Object entityOrProxy, boolean readOnly)Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode.booleanshouldAutoClose()booleanshouldAutoJoinTransaction()Indicates whether an active transaction should be automatically joined.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 Transaction<T> Tunwrap(Class<T> cls)voidupdate(Object object)Update the persistent instance with the identifier of the given detached instance.voidupdate(String entityName, Object object)Update the persistent instance with the identifier of the given detached instance.booleanuseStreamForLobBinding()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.engine.spi.SharedSessionContractImplementor
getConfiguredJdbcBatchSize, getSessionToken, getTypeConfiguration, isEnforcingFetchGraph, setEnforcingFetchGraph
-
-
-
-
Field Detail
-
delegate
protected final SessionImplementor delegate
-
-
Constructor Detail
-
SessionDelegatorBaseImpl
public SessionDelegatorBaseImpl(SessionImplementor delegate)
-
-
Method Detail
-
delegate
protected SessionImplementor delegate()
Returns the underlying delegate. Be careful that it has a different behavior from thegetDelegate()method coming from the EntityManager interface which returns the current session.- See Also:
getDelegate()
-
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.
-
getTenantIdentifier
public String getTenantIdentifier()
Description copied from interface:SharedSessionContractObtain the tenant identifier associated with this session.- Specified by:
getTenantIdentifierin interfaceSharedSessionContract- Specified by:
getTenantIdentifierin interfaceSharedSessionContractImplementor- Returns:
- The tenant identifier associated with this session, or
null
-
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
-
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
-
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.
-
setAutoClear
public void setAutoClear(boolean enabled)
Description copied from interface:SharedSessionContractImplementorEnable/disable automatic cache clearing from after transaction completion (for EJB3)- Specified by:
setAutoClearin 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
-
initializeCollection
public void initializeCollection(PersistentCollection<?> collection, boolean writing) throws HibernateException
Description copied from interface:SharedSessionContractImplementorInitialize the collection (if not already initialized)- Specified by:
initializeCollectionin interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
internalLoad
public Object internalLoad(String entityName, Object id, boolean eager, boolean nullable) throws HibernateException
Description copied from interface:SharedSessionContractImplementorLoad an instance without checking if it was deleted. Whennullableis disabled this method may create a new proxy or return an existing proxy; if it does not exist, throw an exception. Whennullableis enabled, the method does not create new proxies (but might return an existing proxy); if it does not exist, returnnull. Wheneageris enabled, the object is eagerly fetched- Specified by:
internalLoadin interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
immediateLoad
public Object immediateLoad(String entityName, Object id) throws HibernateException
Description copied from interface:SharedSessionContractImplementorLoad an instance immediately. This method is only called when lazily initializing a proxy. Do not return the proxy.- Specified by:
immediateLoadin interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
getFactory
public SessionFactoryImplementor getFactory()
Description copied from interface:SharedSessionContractImplementorGet the creatingSessionFactoryImplementor- Specified by:
getFactoryin interfaceQueryProducerImplementor- Specified by:
getFactoryin interfaceSharedSessionContractImplementor
-
getEntityPersister
public EntityPersister getEntityPersister(String entityName, Object object) throws HibernateException
Description copied from interface:SharedSessionContractImplementorGet theEntityPersisterfor any instance- Specified by:
getEntityPersisterin interfaceSharedSessionContractImplementor- Parameters:
entityName- optional entity nameobject- the entity instance- Throws:
HibernateException
-
getEntityUsingInterceptor
public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException
Description copied from interface:SharedSessionContractImplementorGet the entity instance associated with the givenKey, calling the Interceptor if necessary- Specified by:
getEntityUsingInterceptorin interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
getContextEntityIdentifier
public Object getContextEntityIdentifier(Object object)
Description copied from interface:SharedSessionContractImplementorReturn the identifier of the persistent object, or null if not associated with the session- Specified by:
getContextEntityIdentifierin interfaceSharedSessionContractImplementor
-
bestGuessEntityName
public String bestGuessEntityName(Object object)
Description copied from interface:SharedSessionContractImplementorThe best guess entity name for an entity not in an association- Specified by:
bestGuessEntityNamein interfaceSharedSessionContractImplementor
-
guessEntityName
public String guessEntityName(Object entity) throws HibernateException
Description copied from interface:SharedSessionContractImplementorThe guessed entity name for an entity not in an association- Specified by:
guessEntityNamein interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
instantiate
public Object instantiate(String entityName, Object id) throws HibernateException
Description copied from interface:SharedSessionContractImplementorInstantiate the entity class, initializing with the given identifier- Specified by:
instantiatein interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
getPersistenceContext
public PersistenceContext getPersistenceContext()
Description copied from interface:SharedSessionContractImplementorGet the persistence context for this session. See alsoSharedSessionContractImplementor.getPersistenceContextInternal()for an alternative. This method is not extremely fast: if you need to access the PersistenceContext multiple times, prefer keeping a reference to it over invoking this method multiple times.- Specified by:
getPersistenceContextin interfaceSharedSessionContractImplementor
-
getCacheMode
public CacheMode getCacheMode()
Description copied from interface:SessionGet the currentcache modefor this session.- Specified by:
getCacheModein interfaceQueryProducerImplementor- Specified by:
getCacheModein interfaceSession- Specified by:
getCacheModein interfaceSharedSessionContractImplementor- Returns:
- the current cache mode
-
setCacheMode
public void setCacheMode(CacheMode cm)
Description copied from interface:SessionSet the currentcache modefor this session.The cache mode determines the manner in which this session can interact with the second level cache.
- Specified by:
setCacheModein interfaceSession- Specified by:
setCacheModein interfaceSharedSessionContractImplementor- Parameters:
cm- the new cache mode
-
setCriteriaCopyTreeEnabled
public void setCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled)
- Specified by:
setCriteriaCopyTreeEnabledin interfaceSharedSessionContractImplementor
-
isCriteriaCopyTreeEnabled
public boolean isCriteriaCopyTreeEnabled()
- Specified by:
isCriteriaCopyTreeEnabledin interfaceSharedSessionContractImplementor
-
isOpen
public boolean isOpen()
Description copied from interface:SharedSessionContractCheck if the session is still open.- Specified by:
isOpenin interfacejakarta.persistence.EntityManager- Specified by:
isOpenin interfaceSharedSessionContract- Returns:
- boolean
-
isConnected
public boolean isConnected()
Description copied from interface:SharedSessionContractCheck if the session is currently connected.- Specified by:
isConnectedin interfaceSharedSessionContract- Returns:
- boolean
-
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
-
markForRollbackOnly
public void markForRollbackOnly()
Description copied from interface:SharedSessionContractImplementorMarks current transaction (if one) for rollback only- Specified by:
markForRollbackOnlyin interfaceSharedSessionContractImplementor
-
getTransactionStartTimestamp
public long getTransactionStartTimestamp()
Description copied from interface:SharedSessionContractImplementorA "timestamp" at or before the start of the current transaction.- Specified by:
getTransactionStartTimestampin interfaceSharedSessionContractImplementor
-
getFlushMode
public jakarta.persistence.FlushModeType getFlushMode()
Description copied from interface:SessionGet the currentJPA flush modefor this session.- Specified by:
getFlushModein interfacejakarta.persistence.EntityManager- Specified by:
getFlushModein interfaceSession- Specified by:
getFlushModein interfaceSharedSessionContractImplementor- Returns:
- the
FlushModeTypecurrently in effect
-
setFlushMode
public void setFlushMode(jakarta.persistence.FlushModeType flushModeType)
Description copied from interface:SessionSet the currentJPA flush modefor this session.Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory. The current flush mode determines when the session is automatically flushed.
- Specified by:
setFlushModein interfacejakarta.persistence.EntityManager- Specified by:
setFlushModein interfaceSession- Parameters:
flushModeType- the newFlushModeType- See Also:
for additional options
-
setHibernateFlushMode
public void setHibernateFlushMode(FlushMode flushMode)
Description copied from interface:SessionSet the currentflush modefor this session.Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory. The current flush mode determines when the session is automatically flushed.
The
default flush modeis sometimes unnecessarily aggressive. For a logically "read only" session, it's reasonable to set the session's flush mode toFlushMode.MANUALat the start of the session in order to avoid some unnecessary work.Note that
FlushModedefines more options thanFlushModeType.- Specified by:
setHibernateFlushModein interfaceSession- Specified by:
setHibernateFlushModein interfaceSharedSessionContractImplementor- Parameters:
flushMode- the newFlushMode
-
getHibernateFlushMode
public FlushMode getHibernateFlushMode()
Description copied from interface:SessionGet the currentflush modefor this session.- Specified by:
getHibernateFlushModein interfaceQueryProducerImplementor- Specified by:
getHibernateFlushModein interfaceSession- Specified by:
getHibernateFlushModein interfaceSharedSessionContractImplementor- Returns:
- the
FlushModecurrently in effect
-
lock
public void lock(Object entity, jakarta.persistence.LockModeType lockMode)
- Specified by:
lockin interfacejakarta.persistence.EntityManager
-
lock
public void lock(Object entity, jakarta.persistence.LockModeType lockMode, Map<String,Object> properties)
- Specified by:
lockin interfacejakarta.persistence.EntityManager
-
flush
public void flush()
Description copied from interface:SessionForce this session to flush. Must be called at the end of a unit of work, before the transaction is committed. Depending on the currentSession.setHibernateFlushMode(FlushMode)flush mode}, the session might automatically flush whenEntityTransaction.commit()is called, and it is not necessary to call this method directly.Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.
- Specified by:
flushin interfacejakarta.persistence.EntityManager- Specified by:
flushin interfaceSession- Specified by:
flushin interfaceSharedSessionContractImplementor
-
isEventSource
public boolean isEventSource()
- Specified by:
isEventSourcein interfaceSharedSessionContractImplementor
-
afterScrollOperation
public void afterScrollOperation()
- Specified by:
afterScrollOperationin interfaceSharedSessionContractImplementor
-
getTransactionCoordinator
public TransactionCoordinator getTransactionCoordinator()
Description copied from interface:JdbcSessionOwnerObtain the builder for TransactionCoordinator instances- Specified by:
getTransactionCoordinatorin interfaceJdbcSessionOwner- Returns:
- The TransactionCoordinatorBuilder
-
getJdbcCoordinator
public JdbcCoordinator getJdbcCoordinator()
- Specified by:
getJdbcCoordinatorin interfaceSharedSessionContractImplementor
-
getJdbcServices
public JdbcServices getJdbcServices()
- Specified by:
getJdbcServicesin interfaceSharedSessionContractImplementor
-
getJdbcSessionContext
public JdbcSessionContext getJdbcSessionContext()
- Specified by:
getJdbcSessionContextin interfaceJdbcSessionOwner
-
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.
-
checkOpen
public void checkOpen()
Description copied from interface:SharedSessionContractImplementorPerforms a check whether the Session is open, and if not:- marks current transaction (if one) for rollback only
- throws an IllegalStateException (JPA defines the exception type)
- Specified by:
checkOpenin interfaceSharedSessionContractImplementor
-
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.
-
shouldAutoClose
public boolean shouldAutoClose()
- Specified by:
shouldAutoClosein interfaceSharedSessionContractImplementor
-
isAutoCloseSessionEnabled
public boolean isAutoCloseSessionEnabled()
- Specified by:
isAutoCloseSessionEnabledin interfaceSharedSessionContractImplementor
-
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).
-
getLoadQueryInfluencers
public LoadQueryInfluencers getLoadQueryInfluencers()
Description copied from interface:SharedSessionContractImplementorGet the load query influencers associated with this session.- Specified by:
getLoadQueryInfluencersin interfaceSharedSessionContractImplementor- Returns:
- the load query influencers associated with this session; should never be null.
-
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.
-
getPersistenceContextInternal
public PersistenceContext getPersistenceContextInternal()
Description copied from interface:SharedSessionContractImplementorThis is similar toSharedSessionContractImplementor.getPersistenceContext(), with two main differences: a) this version performs better as it allows for inlining and probably better prediction b) see SessionImplSharedSessionContractImplementor.getPersistenceContext(): it does some checks on the current state of the Session. Choose wisely: performance is important, correctness comes first.- Specified by:
getPersistenceContextInternalin interfaceSharedSessionContractImplementor- Returns:
- the PersistenceContext associated to this session.
-
autoFlushIfRequired
public boolean autoFlushIfRequired(Set<String> querySpaces) throws HibernateException
Description copied from interface:SharedSessionContractImplementordetect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flush- Specified by:
autoFlushIfRequiredin interfaceSharedSessionContractImplementor- Parameters:
querySpaces- the tables named in the query.- Returns:
- true if flush is required, false otherwise.
- Throws:
HibernateException
-
afterOperation
public void afterOperation(boolean success)
Description copied from interface:SharedSessionContractImplementorCheck if there is a Hibernate or JTA transaction in progress and, if there is not, flush if necessary, make sure the connection has been committed (if it is not in autocommit mode) and run the after completion processing- Specified by:
afterOperationin interfaceSharedSessionContractImplementor- Parameters:
success- Was the operation a success
-
getEventListenerManager
public SessionEventListenerManager getEventListenerManager()
- Specified by:
getEventListenerManagerin interfaceSharedSessionContractImplementor
-
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
-
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()
-
getTransaction
public Transaction getTransaction()
Description copied from interface:SharedSessionContractGet theTransactioninstance associated with this session.- Specified by:
getTransactionin interfacejakarta.persistence.EntityManager- Specified by:
getTransactionin interfaceSharedSessionContract- Returns:
- a Transaction instance
-
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
-
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
-
afterTransactionBegin
public void afterTransactionBegin()
Description copied from interface:JdbcSessionOwnerA after-begin callback from the coordinator to its owner.- Specified by:
afterTransactionBeginin 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)?
-
flushBeforeTransactionCompletion
public void flushBeforeTransactionCompletion()
- Specified by:
flushBeforeTransactionCompletionin interfaceJdbcSessionOwner
-
getEntityManagerFactory
public jakarta.persistence.EntityManagerFactory getEntityManagerFactory()
- Specified by:
getEntityManagerFactoryin interfacejakarta.persistence.EntityManager
-
getCriteriaBuilder
public HibernateCriteriaBuilder getCriteriaBuilder()
Description copied from interface:SharedSessionContractReturn an instance ofCriteriaBuilder.- Specified by:
getCriteriaBuilderin interfacejakarta.persistence.EntityManager- Specified by:
getCriteriaBuilderin interfaceSharedSessionContract- Returns:
- an instance of CriteriaBuilder
-
getMetamodel
public jakarta.persistence.metamodel.Metamodel getMetamodel()
- Specified by:
getMetamodelin interfacejakarta.persistence.EntityManager
-
createEntityGraph
public <T> RootGraphImplementor<T> createEntityGraph(Class<T> rootType)
- Specified by:
createEntityGraphin interfacejakarta.persistence.EntityManager- Specified by:
createEntityGraphin interfaceSession- Specified by:
createEntityGraphin interfaceSessionImplementor
-
createEntityGraph
public RootGraphImplementor<?> createEntityGraph(String graphName)
- Specified by:
createEntityGraphin interfacejakarta.persistence.EntityManager- Specified by:
createEntityGraphin interfaceSession- Specified by:
createEntityGraphin interfaceSessionImplementor
-
getEntityGraph
public RootGraphImplementor<?> getEntityGraph(String graphName)
- Specified by:
getEntityGraphin interfacejakarta.persistence.EntityManager- Specified by:
getEntityGraphin interfaceSession- Specified by:
getEntityGraphin interfaceSessionImplementor
-
getEntityGraphs
public <T> List<jakarta.persistence.EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass)
- Specified by:
getEntityGraphsin interfacejakarta.persistence.EntityManager- Specified by:
getEntityGraphsin interfaceSession
-
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
-
createQuery
public <T> QueryImplementor<T> createQuery(jakarta.persistence.criteria.CriteriaQuery<T> criteriaQuery)
Description copied from interface:QueryProducerCreate aQueryfor the given JPACriteriaQuery- Specified by:
createQueryin interfacejakarta.persistence.EntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor- Specified by:
createQueryin interfaceSession
-
createQuery
public QueryImplementor createQuery(jakarta.persistence.criteria.CriteriaUpdate updateQuery)
Description copied from interface:SessionCreate aQueryfor the given JPACriteriaUpdate- Specified by:
createQueryin interfacejakarta.persistence.EntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor- Specified by:
createQueryin interfaceSession
-
createQuery
public QueryImplementor createQuery(jakarta.persistence.criteria.CriteriaDelete deleteQuery)
Description copied from interface:SessionCreate aQueryfor the given JPACriteriaDelete- Specified by:
createQueryin interfacejakarta.persistence.EntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor- Specified by:
createQueryin interfaceSession
-
getNamedQuery
public QueryImplementor getNamedQuery(String name)
Description copied from interface:QueryProducerCreate aQueryinstance for the named query.- Specified by:
getNamedQueryin interfaceQueryProducer- Specified by:
getNamedQueryin interfaceQueryProducerImplementor- Parameters:
name- the name of a pre-defined, named query- Returns:
- The
Queryinstance for manipulation and execution
-
getNamedNativeQuery
public NativeQueryImplementor getNamedNativeQuery(String name)
Description copied from interface:QueryProducerGet aNativeQueryinstance for a named native SQL query- Specified by:
getNamedNativeQueryin interfaceQueryProducer- Specified by:
getNamedNativeQueryin interfaceQueryProducerImplementor- Parameters:
name- The name of the pre-defined query- Returns:
- The
NativeQueryinstance for manipulation and execution
-
getNamedNativeQuery
public NativeQueryImplementor getNamedNativeQuery(String name, String resultSetMapping)
Description copied from interface:QueryProducerGet aNativeQueryinstance for a named native SQL query- Specified by:
getNamedNativeQueryin interfaceQueryProducer- Specified by:
getNamedNativeQueryin interfaceQueryProducerImplementor- Parameters:
name- The name of the pre-defined query- Returns:
- The
NativeQueryinstance for manipulation and execution
-
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 interfacejakarta.persistence.EntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor- Specified by:
createQueryin interfaceSession- 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> resultType)
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> resultType)
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 interfacejakarta.persistence.EntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor- Specified by:
createQueryin interfaceSession- Parameters:
queryString- The HQL queryresultType- The type of the query result- Returns:
- The Query instance for manipulation and execution
- See Also:
EntityManager.createQuery(String,Class)
-
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 interfacejakarta.persistence.EntityManager- Specified by:
createNamedQueryin interfaceQueryProducer- Specified by:
createNamedQueryin interfaceQueryProducerImplementor- Specified by:
createNamedQueryin interfaceSession- Parameters:
name- the name of a pre-defined, named query- Returns:
- The
Queryinstance for manipulation and execution - See Also:
EntityManager.createNamedQuery(String)
-
createNamedQuery
public <T> QueryImplementor<T> createNamedQuery(String name, Class<T> 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 interfacejakarta.persistence.EntityManager- Specified by:
createNamedQueryin interfaceQueryProducer- Specified by:
createNamedQueryin interfaceQueryProducerImplementor- Specified by:
createNamedQueryin interfaceSession- 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 name)
Description copied from interface:QueryProducerCreate aSelectionQueryinstance for the namedNamedQuery- Specified by:
createNamedSelectionQueryin interfaceQueryProducer
-
createNamedSelectionQuery
public <R> SelectionQuery<R> createNamedSelectionQuery(String name, Class<R> resultType)
Description copied from interface:QueryProducerCreate aSelectionQueryinstance for the namedNamedQuerywith the expected result-type- Specified by:
createNamedSelectionQueryin interfaceQueryProducer
-
createNativeQuery
public NativeQueryImplementor createNativeQuery(String sqlString)
Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native (SQL) query- Specified by:
createNativeQueryin interfacejakarta.persistence.EntityManager- 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, 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 interfacejakarta.persistence.EntityManager- 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 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 interfacejakarta.persistence.EntityManager- 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 <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
-
createMutationQuery
public MutationQuery createMutationQuery(String statementString)
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
-
createNamedMutationQuery
public MutationQuery createNamedMutationQuery(String name)
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
-
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
-
createNamedStoredProcedureQuery
public ProcedureCall createNamedStoredProcedureQuery(String name)
Description copied from interface:SharedSessionContractObtain aProcedureCallbased on a named template- Specified by:
createNamedStoredProcedureQueryin interfacejakarta.persistence.EntityManager- Specified by:
createNamedStoredProcedureQueryin interfaceSharedSessionContract- Parameters:
name- The name given to the template- Returns:
- The ProcedureCall
- See Also:
NamedStoredProcedureQuery
-
createStoredProcedureQuery
public ProcedureCall createStoredProcedureQuery(String procedureName)
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure.- Specified by:
createStoredProcedureQueryin interfacejakarta.persistence.EntityManager- 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 interfacejakarta.persistence.EntityManager- 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 interfacejakarta.persistence.EntityManager- 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.
-
prepareForQueryExecution
public void prepareForQueryExecution(boolean requiresTxn)
Description copied from interface:SharedSessionContractImplementorPrepare for the execution of aQueryorProcedureCall- Specified by:
prepareForQueryExecutionin interfaceSharedSessionContractImplementor
-
joinTransaction
public void joinTransaction()
- Specified by:
joinTransactionin interfacejakarta.persistence.EntityManager
-
isJoinedToTransaction
public boolean isJoinedToTransaction()
- Specified by:
isJoinedToTransactionin interfacejakarta.persistence.EntityManager
-
unwrap
public <T> T unwrap(Class<T> cls)
- Specified by:
unwrapin interfacejakarta.persistence.EntityManager
-
getDelegate
public Object getDelegate()
This is an implementation of EntityManager#getDelegate(). It returns the current session and not the delegate session as it is what we want. The name of the method is misleading here but, as it is part of JPA, we cannot do anything about it.To get the underlying delegate, use
delegate()instead.- Specified by:
getDelegatein interfacejakarta.persistence.EntityManager- See Also:
delegate()
-
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
-
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.
-
sessionWithOptions
public SharedSessionBuilder sessionWithOptions()
Description copied from interface:SessionObtain aSessionbuilder with the ability to copy certain information from this session.- Specified by:
sessionWithOptionsin interfaceSession- Returns:
- the session builder
-
getSessionFactory
public SessionFactoryImplementor getSessionFactory()
Description copied from interface:SessionGet the session factory which created this session.- Specified by:
getSessionFactoryin interfaceSession- Specified by:
getSessionFactoryin interfaceSessionImplementor- Specified by:
getSessionFactoryin interfaceSharedSessionContractImplementor- Specified by:
getSessionFactoryin interfaceWrapperOptions- Returns:
- the session factory
- See Also:
SessionFactory
-
close
public void close() throws HibernateExceptionDescription 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 interfacejakarta.persistence.EntityManager- Specified by:
closein interfaceSharedSessionContract- Throws:
HibernateException- Indicates problems cleaning up.
-
cancelQuery
public void cancelQuery() throws HibernateExceptionDescription copied from interface:SessionCancel the execution of the current query. This is the sole method on session which may be safely called from another thread.- Specified by:
cancelQueryin interfaceSession- Throws:
HibernateException- if there was a problem cancelling the query
-
isDirty
public boolean isDirty() throws HibernateExceptionDescription copied from interface:SessionDoes this session contain any changes which must be synchronized with the database? In other words, would any DML operations be executed if we flushed this session?- Specified by:
isDirtyin interfaceSession- Returns:
trueif the session contains pending changes;falseotherwise.- Throws:
HibernateException- could not perform dirtying checking
-
isDefaultReadOnly
public boolean isDefaultReadOnly()
Description copied from interface:SessionWill entities and proxies that are loaded into this session be made read-only by default?To determine the read-only/modifiable setting for a particular entity or proxy use
Session.isReadOnly(Object).- Specified by:
isDefaultReadOnlyin interfaceSession- Specified by:
isDefaultReadOnlyin interfaceSharedSessionContractImplementor- Returns:
true, loaded entities/proxies will be made read-only by default;false, loaded entities/proxies will be made modifiable by default.- See Also:
Session.isReadOnly(Object)
-
setDefaultReadOnly
public void setDefaultReadOnly(boolean readOnly)
Description copied from interface:SessionChange the default for entities and proxies loaded into this session from modifiable to read-only mode, or from modifiable to read-only mode.Read-only entities are not dirty-checked and snapshots of persistent state are not maintained. Read-only entities can be modified, but changes are not persisted.
When a proxy is initialized, the loaded entity will have the same read-only/modifiable setting as the uninitialized proxy has, regardless of the session's current setting.
To change the read-only/modifiable setting for a particular entity or proxy that already belongs to this session use
Session.setReadOnly(Object, boolean).To override this session's read-only/modifiable setting for all entities and proxies loaded by a certain
QueryuseQuery.setReadOnly(boolean).- Specified by:
setDefaultReadOnlyin interfaceSession- Parameters:
readOnly-true, the default for loaded entities/proxies is read-only;false, the default for loaded entities/proxies is modifiable- See Also:
Session.setReadOnly(Object,boolean),Query.setReadOnly(boolean)
-
getIdentifier
public Object getIdentifier(Object object)
Description copied from interface:SessionReturn the identifier value of the given entity associated with this session. An exception is thrown if the given entity instance is transient or detached in relation to this session.- Specified by:
getIdentifierin interfaceSession- Parameters:
object- a persistent instance associated with this session- Returns:
- the identifier
-
contains
public boolean contains(String entityName, Object object)
Description copied from interface:SessionDetermine if the given entity is associated with this session.
-
contains
public boolean contains(Object object)
- Specified by:
containsin interfacejakarta.persistence.EntityManager
-
getLockMode
public jakarta.persistence.LockModeType getLockMode(Object entity)
- Specified by:
getLockModein interfacejakarta.persistence.EntityManager
-
setProperty
public void setProperty(String propertyName, Object value)
- Specified by:
setPropertyin interfacejakarta.persistence.EntityManager
-
getProperties
public Map<String,Object> getProperties()
- Specified by:
getPropertiesin interfacejakarta.persistence.EntityManager
-
evict
public void evict(Object object)
Description copied from interface:SessionRemove this instance from the session cache. Changes to the instance will not be synchronized with the database. This operation cascades to associated instances if the association is mapped withCascadeType.DETACH.This operation is a synonym for
Session.detach(Object).
-
load
public <T> T load(Class<T> theClass, Object id, LockMode lockMode)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists. Convenient form ofSession.load(Class, Object, LockOptions).- Specified by:
loadin interfaceSession- Parameters:
theClass- a persistent classid- a valid identifier of an existing persistent instance of the classlockMode- the lock level- Returns:
- the persistent instance or proxy
- See Also:
Session.load(Class, Object, LockOptions)
-
load
public <T> T load(Class<T> theClass, Object id, LockOptions lockOptions)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
-
load
public Object load(String entityName, Object id, LockMode lockMode)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists. Convenient form ofSession.load(String, Object, LockOptions).- Specified by:
loadin interfaceSession- Parameters:
entityName- a persistent classid- a valid identifier of an existing persistent instance of the classlockMode- the lock level- Returns:
- the persistent instance or proxy
- See Also:
Session.load(String, Object, LockOptions)
-
load
public Object load(String entityName, Object id, LockOptions lockOptions)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
-
load
public <T> T load(Class<T> theClass, Object id)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, making the assumption that the instance exists in the database. This method might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed.You should not use this method to determine if an instance exists in the database (use
get()instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.This operation is very similar to
Session.getReference(Class, Object).
-
load
public Object load(String entityName, Object id)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, making the assumption that the instance exists in the database. This method might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed.You should not use this method to determine if an instance exists in the database (use
get()instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.
-
load
public void load(Object object, Object id)
Description copied from interface:SessionRead the persistent state associated with the given identifier into the given transient instance.
-
replicate
public void replicate(Object object, ReplicationMode replicationMode)
Description copied from interface:SessionPersist the state of the given detached instance, reusing the current identifier value. This operation cascades to associated instances if the association is mapped withCascadeType.REPLICATE.
-
replicate
public void replicate(String entityName, Object object, ReplicationMode replicationMode)
Description copied from interface:SessionPersist the state of the given detached instance, reusing the current identifier value. This operation cascades to associated instances if the association is mapped withCascadeType.REPLICATE.
-
save
public Object save(Object object)
Description copied from interface:SessionPersist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if theassignedgenerator is used.) This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE.This operation is very similar to
Session.persist(Object).
-
save
public Object save(String entityName, Object object)
Description copied from interface:SessionPersist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if theassignedgenerator is used.) This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE.
-
saveOrUpdate
public void saveOrUpdate(Object object)
Description copied from interface:SessionEitherSession.save(Object)orSession.update(Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking). This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE.- Specified by:
saveOrUpdatein interfaceSession- Parameters:
object- a transient or detached instance containing new or updated state- See Also:
Session.save(Object),Session.update(Object object)
-
saveOrUpdate
public void saveOrUpdate(String entityName, Object object)
Description copied from interface:SessionEitherSession.save(String, Object)orSession.update(String, Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking). This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE.- Specified by:
saveOrUpdatein interfaceSession- Parameters:
entityName- the entity nameobject- a transient or detached instance containing new or updated state- See Also:
Session.save(String,Object),Session.update(String,Object)
-
update
public void update(Object object)
Description copied from interface:SessionUpdate the persistent instance with the identifier of the given detached instance. If there is a persistent instance with the same identifier, an exception is thrown. This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE.
-
update
public void update(String entityName, Object object)
Description copied from interface:SessionUpdate the persistent instance with the identifier of the given detached instance. If there is a persistent instance with the same identifier, an exception is thrown. This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE.
-
merge
public <T> T merge(T object)
Description copied from interface:SessionCopy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved, save a copy and return it as a newly persistent instance. The given instance does not become associated with the session. This operation cascades to associated instances if the association is mapped withCascadeType.MERGE.
-
merge
public <T> T merge(String entityName, T object)
Description copied from interface:SessionCopy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved, save a copy and return it as a newly persistent instance. The given instance does not become associated with the session. This operation cascades to associated instances if the association is mapped withCascadeType.MERGE.
-
persist
public void persist(Object object)
Description copied from interface:SessionMake a transient instance persistent and mark it for later insertion in the database. This operation cascades to associated instances if the association is mapped withCascadeType.PERSIST.For entities with a
generated id,persist()ultimately results in generation of an identifier for the given instance. But this may happen asynchronously, when the session is flushed, depending on the identifier generation strategy.
-
remove
public void remove(Object entity)
Description copied from interface:SessionMark a persistence instance associated with this session for removal from the underlying database. Ths operation cascades to associated instances if the association is mappedCascadeType.REMOVE.
-
find
public <T> T find(Class<T> entityClass, Object primaryKey)
- Specified by:
findin interfacejakarta.persistence.EntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, Map<String,Object> properties)
- Specified by:
findin interfacejakarta.persistence.EntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, jakarta.persistence.LockModeType lockMode)
- Specified by:
findin interfacejakarta.persistence.EntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, jakarta.persistence.LockModeType lockMode, Map<String,Object> properties)
- Specified by:
findin interfacejakarta.persistence.EntityManager
-
getReference
public <T> T getReference(Class<T> entityClass, Object id)
Description copied from interface:SessionReturn a reference to the persistent instance with the given class and identifier, making the assumption that the instance is still persistent in the database. This method never results in access to the underlying data store, and thus might return a proxy that is initialized on-demand, when a non-identifier method is accessed.Note that
Hibernate.createDetachedProxy(SessionFactory, Class, Object)may be used to obtain a detached reference.- Specified by:
getReferencein interfacejakarta.persistence.EntityManager- Specified by:
getReferencein interfaceSession- Parameters:
entityClass- the entity typeid- the identifier of a persistent instance that exists in the database- Returns:
- the persistent instance or proxy
-
getReference
public Object getReference(String entityName, Object id)
Description copied from interface:SessionReturn a reference to the persistent instance of the given named entity with the given identifier, making the assumption that the instance is still persistent in the database. This method never results in access to the underlying data store, and thus might return a proxy that is initialized on-demand, when a non-identifier method is accessed.- Specified by:
getReferencein interfaceSession- Parameters:
entityName- the entity nameid- the identifier of a persistent instance that exists in the database- Returns:
- the persistent instance or proxy
-
persist
public void persist(String entityName, Object object)
Description copied from interface:SessionMake a transient instance persistent and mark it for later insertion in the database. This operation cascades to associated instances if the association is mapped withCascadeType.PERSIST.For entities with a
generated id,persist()ultimately results in generation of an identifier for the given instance. But this may happen asynchronously, when the session is flushed, depending on the identifier generation strategy.
-
delete
public void delete(Object object)
Description copied from interface:SessionRemove a persistent instance from the datastore. The argument may be an instance associated with the receivingSessionor a transient instance with an identifier associated with existing persistent state. This operation cascades to associated instances if the association is mapped withCascadeType.REMOVE.
-
delete
public void delete(String entityName, Object object)
Description copied from interface:SessionRemove a persistent instance from the datastore. The second argument may be an instance associated with the receivingSessionor a transient instance with an identifier associated with existing persistent state. This operation cascades to associated instances if the association is mapped withCascadeType.REMOVE.
-
lock
public void lock(Object object, LockMode lockMode)
Description copied from interface:SessionObtain the specified lock level on the given managed instance association with this session. This may be used to:- perform a version check with
LockMode.READ, or - upgrade to a pessimistic lock with
LockMode.PESSIMISTIC_WRITE).
CascadeType.LOCK.Convenient form of
Session.LockRequest.lock(Object)viaSession.buildLockRequest(LockOptions)- Specified by:
lockin interfaceSession- Parameters:
object- a persistent or transient instancelockMode- the lock level- See Also:
Session.buildLockRequest(LockOptions),Session.LockRequest.lock(Object)
- perform a version check with
-
lock
public void lock(String entityName, Object object, LockMode lockMode)
Description copied from interface:SessionObtain the specified lock level on the given managed instance association with this session. This may be used to:- perform a version check with
LockMode.READ, or - upgrade to a pessimistic lock with
LockMode.PESSIMISTIC_WRITE).
CascadeType.LOCK.Convenient form of
Session.LockRequest.lock(String, Object)viaSession.buildLockRequest(LockOptions)- Specified by:
lockin interfaceSession- Parameters:
entityName- the name of the entityobject- a persistent or transient instancelockMode- the lock level- See Also:
Session.buildLockRequest(LockOptions),Session.LockRequest.lock(String, Object)
- perform a version check with
-
buildLockRequest
public Session.LockRequest buildLockRequest(LockOptions lockOptions)
Description copied from interface:SessionBuild a newlock requestthat specifies: Timeout and scope are ignored if the specifiedLockModerepresents a form of optimistic locking.Call
Session.LockRequest.lock(Object)to actually obtain the requested lock on a managed entity instance.Example usage:
session.buildLockRequest().setLockMode(LockMode.PESSIMISTIC_WRITE).setTimeOut(60000).lock(entity);- Specified by:
buildLockRequestin interfaceSession- Parameters:
lockOptions- contains the lock level- Returns:
- a
Session.LockRequestthat can be used to lock any given object.
-
refresh
public void refresh(Object object)
Description copied from interface:SessionReread the state of the given managed instance associated with this session from the underlying database. This may be useful:- when a database trigger alters the object state upon insert or update
- after executing any HQL update or delete statement
- after executing a native SQL statement
- after inserting a
BloborClob
CascadeType.REFRESH.
-
refresh
public void refresh(Object entity, Map<String,Object> properties)
- Specified by:
refreshin interfacejakarta.persistence.EntityManager
-
refresh
public void refresh(Object entity, jakarta.persistence.LockModeType lockMode)
- Specified by:
refreshin interfacejakarta.persistence.EntityManager
-
refresh
public void refresh(Object entity, jakarta.persistence.LockModeType lockMode, Map<String,Object> properties)
- Specified by:
refreshin interfacejakarta.persistence.EntityManager
-
refresh
public void refresh(String entityName, Object object)
Description copied from interface:SessionReread the state of the given managed instance associated with this session from the underlying database. This may be useful:- when a database trigger alters the object state upon insert or update
- after executing any HQL update or delete statement
- after executing a native SQL statement
- after inserting a
BloborClob
CascadeType.REFRESH.
-
refresh
public void refresh(Object object, LockMode lockMode)
Description copied from interface:SessionReread the state of the given managed instance from the underlying database, obtaining the givenLockMode.Convenient form of
Session.refresh(Object, LockOptions)- Specified by:
refreshin interfaceSession- Parameters:
object- a persistent or detached instancelockMode- the lock mode to use- See Also:
Session.refresh(Object, LockOptions)
-
refresh
public void refresh(Object object, LockOptions lockOptions)
Description copied from interface:SessionReread the state of the given managed instance from the underlying database, obtaining the givenLockMode.
-
refresh
public void refresh(String entityName, Object object, LockOptions lockOptions)
Description copied from interface:SessionReread the state of the given managed instance from the underlying database, obtaining the givenLockMode.
-
getCurrentLockMode
public LockMode getCurrentLockMode(Object object)
Description copied from interface:SessionDetermine the currentLockModeof the given managed instance associated with this session.- Specified by:
getCurrentLockModein interfaceSession- Parameters:
object- a persistent instance- Returns:
- the current lock mode
-
clear
public void clear()
Description copied from interface:SessionCompletely clear the session. Evict all loaded instances and cancel all pending saves, updates and deletions. Do not close open iterators or instances ofScrollableResults.
-
detach
public void detach(Object entity)
Description copied from interface:SessionRemove this instance from the session cache. Changes to the instance will not be synchronized with the database. This operation cascades to associated instances if the association is mapped withCascadeType.DETACH.
-
get
public <T> T get(Class<T> theClass, Object id)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.This operation is very similar to
EntityManager.find(Class, Object).
-
get
public <T> T get(Class<T> theClass, Object id, LockMode lockMode)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance. Obtain the specified lock mode if the instance exists.Convenient form of
Session.get(Class, Object, LockOptions).This operation is very similar to
EntityManager.find(Class, Object, jakarta.persistence.LockModeType).- Specified by:
getin interfaceSession- Parameters:
theClass- the entity typeid- an identifierlockMode- the lock mode- Returns:
- a persistent instance or null
- See Also:
Session.get(Class, Object, LockOptions)
-
get
public <T> T get(Class<T> theClass, Object id, LockOptions lockOptions)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance. Obtain the specified lock mode if the instance exists.
-
get
public Object get(String entityName, Object id)
Description copied from interface:SessionReturn the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.
-
get
public Object get(String entityName, Object id, LockMode lockMode)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.) Obtain the specified lock mode if the instance exists. Convenient form ofSession.get(String, Object, LockOptions)- Specified by:
getin interfaceSession- Parameters:
entityName- the entity nameid- an identifierlockMode- the lock mode- Returns:
- a persistent instance or null
- See Also:
Session.get(String, Object, LockOptions)
-
get
public Object get(String entityName, Object id, LockOptions lockOptions)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance. Obtain the specified lock mode if the instance exists.
-
getEntityName
public String getEntityName(Object object)
Description copied from interface:SessionReturn the entity name for a persistent entity.- Specified by:
getEntityNamein interfaceSession- Parameters:
object- a persistent entity associated with this session- Returns:
- the entity name
-
getReference
public <T> T getReference(T object)
Description copied from interface:SessionReturn a reference to the persistent instance with the same identity as the given instance, which might be detached, making the assumption that the instance is still persistent in the database. This method never results in access to the underlying data store, and thus might return a proxy that is initialized on-demand, when a non-identifier method is accessed.- Specified by:
getReferencein interfaceSession- Parameters:
object- a detached persistent instance- Returns:
- the persistent instance or proxy
-
byId
public <T> IdentifierLoadAccess<T> byId(String entityName)
Description copied from interface:SessionCreate anIdentifierLoadAccessinstance to retrieve the specified entity type by primary key.
-
byMultipleIds
public <T> MultiIdentifierLoadAccess<T> byMultipleIds(Class<T> entityClass)
Description copied from interface:SessionCreate aMultiIdentifierLoadAccessinstance to retrieve multiple entities at once as specified by primary key values.- Specified by:
byMultipleIdsin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by primary key values
-
byMultipleIds
public <T> MultiIdentifierLoadAccess<T> byMultipleIds(String entityName)
Description copied from interface:SessionCreate aMultiIdentifierLoadAccessinstance to retrieve multiple entities at once as specified by primary key values.- Specified by:
byMultipleIdsin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by primary key values
-
byId
public <T> IdentifierLoadAccess<T> byId(Class<T> entityClass)
Description copied from interface:SessionCreate anIdentifierLoadAccessinstance to retrieve the specified entity by primary key.
-
byNaturalId
public <T> NaturalIdLoadAccess<T> byNaturalId(String entityName)
Description copied from interface:SessionCreate aNaturalIdLoadAccessinstance to retrieve the specified entity by its natural id.- Specified by:
byNaturalIdin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by natural id
-
byNaturalId
public <T> NaturalIdLoadAccess<T> byNaturalId(Class<T> entityClass)
Description copied from interface:SessionCreate aNaturalIdLoadAccessinstance to retrieve the specified entity by its natural id.- Specified by:
byNaturalIdin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by natural id
-
bySimpleNaturalId
public <T> SimpleNaturalIdLoadAccess<T> bySimpleNaturalId(String entityName)
Description copied from interface:SessionCreate aSimpleNaturalIdLoadAccessinstance to retrieve the specified entity by itsnatural id.- Specified by:
bySimpleNaturalIdin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by natural id
-
bySimpleNaturalId
public <T> SimpleNaturalIdLoadAccess<T> bySimpleNaturalId(Class<T> entityClass)
Description copied from interface:SessionCreate aSimpleNaturalIdLoadAccessinstance to retrieve the specified entity by its simple (single attribute)natural id.- Specified by:
bySimpleNaturalIdin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by natural id
-
byMultipleNaturalId
public <T> NaturalIdMultiLoadAccess<T> byMultipleNaturalId(Class<T> entityClass)
Description copied from interface:SessionAccess to load multiple entities bynatural id.- Specified by:
byMultipleNaturalIdin interfaceSession
-
byMultipleNaturalId
public <T> NaturalIdMultiLoadAccess<T> byMultipleNaturalId(String entityName)
Description copied from interface:SessionAccess to load multiple entities bynatural id.- Specified by:
byMultipleNaturalIdin interfaceSession
-
enableFilter
public Filter enableFilter(String filterName)
Description copied from interface:SessionEnable the named filter for this current session.- Specified by:
enableFilterin interfaceSession- Parameters:
filterName- the name of the filter to be enabled.- Returns:
- the
Filterinstance representing the enabled filter.
-
getEnabledFilter
public Filter getEnabledFilter(String filterName)
Description copied from interface:SessionRetrieve a currently enabled filter by name.- Specified by:
getEnabledFilterin interfaceSession- Parameters:
filterName- the name of the filter to be retrieved.- Returns:
- the
Filterinstance representing the enabled filter.
-
disableFilter
public void disableFilter(String filterName)
Description copied from interface:SessionDisable the named filter for the current session.- Specified by:
disableFilterin interfaceSession- Parameters:
filterName- the name of the filter to be disabled.
-
getStatistics
public SessionStatistics getStatistics()
Description copied from interface:SessionGet the statistics for this session.- Specified by:
getStatisticsin interfaceSession- Returns:
- the session statistics being collected for this session
-
isReadOnly
public boolean isReadOnly(Object entityOrProxy)
Description copied from interface:SessionIs the specified entity or proxy read-only?To get the default read-only/modifiable setting used for entities and proxies that are loaded into the session use
Session.isDefaultReadOnly()- Specified by:
isReadOnlyin interfaceSession- Parameters:
entityOrProxy- an entity or proxy- Returns:
trueif the entity or proxy is read-only,falseif the entity or proxy is modifiable.- See Also:
Session.isDefaultReadOnly()
-
setReadOnly
public void setReadOnly(Object entityOrProxy, boolean readOnly)
Description copied from interface:SessionSet an unmodified persistent object to read-only mode, or a read-only object to modifiable mode. In read-only mode, no snapshot is maintained, the instance is never dirty checked, and changes are not persisted.If the entity or proxy already has the specified read-only/modifiable setting, then this method does nothing.
To set the default read-only/modifiable setting used for all entities and proxies that are loaded into the session use
Session.setDefaultReadOnly(boolean).To override this session's read-only/modifiable setting for entities and proxies loaded by a
QueryuseQuery.setReadOnly(boolean)- Specified by:
setReadOnlyin interfaceSession- Parameters:
entityOrProxy- an entity or proxyreadOnly-trueif the entity or proxy should be made read-only;falseif the entity or proxy should be made modifiable- See Also:
Session.setDefaultReadOnly(boolean),Query.setReadOnly(boolean)
-
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
-
isFetchProfileEnabled
public boolean isFetchProfileEnabled(String name) throws UnknownProfileException
Description copied from interface:SessionIs a particular fetch profile enabled on this session?- Specified by:
isFetchProfileEnabledin interfaceSession- Parameters:
name- the name of the profile to be checked.- Returns:
- True if fetch profile is enabled; false if not.
- Throws:
UnknownProfileException- Indicates that the given name does not match any known profile names- See Also:
for discussion of this feature
-
enableFetchProfile
public void enableFetchProfile(String name) throws UnknownProfileException
Description copied from interface:SessionEnable a particular fetch profile on this session. If the requested profile is already enabled, the call has no effect.- Specified by:
enableFetchProfilein interfaceSession- Parameters:
name- the name of the fetch profile to be enabled- Throws:
UnknownProfileException- Indicates that the given name does not match any known profile names- See Also:
for discussion of this feature
-
disableFetchProfile
public void disableFetchProfile(String name) throws UnknownProfileException
Description copied from interface:SessionDisable a particular fetch profile on this session. If the requested profile is already enabled, the call has no effect.- Specified by:
disableFetchProfilein interfaceSession- Parameters:
name- the name of the fetch profile to be disabled- Throws:
UnknownProfileException- Indicates that the given name does not match any known profile names- See Also:
for discussion of this feature
-
getLobHelper
public LobHelper getLobHelper()
Description copied from interface:SessionRetrieve this session's helper/delegate for creating LOB instances.- Specified by:
getLobHelperin interfaceSession- Returns:
- this session's
LOB helper
-
addEventListeners
public void addEventListeners(SessionEventListener... listeners)
Description copied from interface:SessionAdd one or more listeners to the Session- Specified by:
addEventListenersin interfaceSession- Parameters:
listeners- the listener(s) to add
-
getActionQueue
public ActionQueue getActionQueue()
- Specified by:
getActionQueuein interfaceSessionImplementor
-
instantiate
public Object instantiate(EntityPersister persister, Object id) throws HibernateException
Description copied from interface:SharedSessionContractImplementorInstantiate the entity class of an EntityPersister, initializing with the given identifier. This is more efficient thanSharedSessionContractImplementor.instantiate(String, Object)but not always interchangeable: a single persister might be responsible for multiple types.- Specified by:
instantiatein interfaceSessionImplementor- Specified by:
instantiatein interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
forceFlush
public void forceFlush(EntityEntry e) throws HibernateException
- Specified by:
forceFlushin interfaceSessionImplementor- Throws:
HibernateException
-
merge
public void merge(String entityName, Object object, MergeContext copiedAlready) throws HibernateException
- Specified by:
mergein interfaceSessionImplementor- Throws:
HibernateException
-
persist
public void persist(String entityName, Object object, PersistContext createdAlready) throws HibernateException
- Specified by:
persistin interfaceSessionImplementor- Throws:
HibernateException
-
persistOnFlush
public void persistOnFlush(String entityName, Object object, PersistContext copiedAlready)
- Specified by:
persistOnFlushin interfaceSessionImplementor
-
refresh
public void refresh(String entityName, Object object, RefreshContext refreshedAlready) throws HibernateException
- Specified by:
refreshin interfaceSessionImplementor- Throws:
HibernateException
-
delete
public void delete(String entityName, Object child, boolean isCascadeDeleteEnabled, DeleteContext transientEntities)
- Specified by:
deletein interfaceSessionImplementor
-
removeOrphanBeforeUpdates
public void removeOrphanBeforeUpdates(String entityName, Object child)
- Specified by:
removeOrphanBeforeUpdatesin interfaceSessionImplementor
-
getSession
public SessionImplementor getSession()
Description copied from interface:WrapperOptionsAccess to the current Session- Specified by:
getSessionin interfaceSessionImplementor- Specified by:
getSessionin interfaceSharedSessionContractImplementor- Specified by:
getSessionin interfaceWrapperOptions
-
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
-
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)
-
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
-
-