Class SessionDelegatorBaseImpl
- All Implemented Interfaces:
EntityManager,Closeable,Serializable,AutoCloseable,LobCreationContext,SessionImplementor,SharedSessionContractImplementor,QueryProducer,QueryProducerImplementor,JdbcSessionOwner,TransactionCoordinatorBuilder.Options,Session,SharedSessionContract,JavaType.CoercionContext,WrapperOptions
- Direct Known Subclasses:
AbstractDelegateSessionImplementor
SessionImplementor. This is useful for custom implementations of that
API, so that only some methods need to be overridden
(Used by Hibernate Search).
- Author:
- Sanne Grinovero
- See Also:
-
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the currentTransaction, or creates a new transaction if there is no transaction 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, making sure that the connection has been committed (if it is not in autocommit mode), and finally run the after completion processing.voidCalled after each operation on aScrollableResults, providing an opportunity for a stateless session to clear its temporary persistence context.voidA after-begin callback from the coordinator to its owner.voidafterTransactionCompletion(boolean successful, boolean delayed) An after-completion callback to the owner.Cast this session toEventSourceif possible.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 flushbooleanautoFlushIfRequired(Set<String> querySpaces, boolean skipPreFlush) voidvoidA before-completion callback to the owner.Begin a unit of work and return the associatedTransactionobject.bestGuessEntityName(Object object) Obtain the best estimate of the entity name of the given entity instance, which is not involved in an association, by also considering information held in the proxy, and whether the object is already associated with this session.buildLockRequest(LockOptions lockOptions) Deprecated.<T> IdentifierLoadAccess<T>Create anIdentifierLoadAccessinstance to retrieve an instance of the given entity type by its primary key.<T> IdentifierLoadAccess<T>Create anIdentifierLoadAccessinstance to retrieve an instance of the named entity type by its primary key.<T> MultiIdentifierLoadAccess<T>byMultipleIds(Class<T> entityClass) Create aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the given entity type by their primary key values, using batching.<T> MultiIdentifierLoadAccess<T>byMultipleIds(String entityName) Create aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the named entity type by their primary key values, using batching.<T> NaturalIdMultiLoadAccess<T>byMultipleNaturalId(Class<T> entityClass) Create aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the given entity type by their by natural id values, using batching.<T> NaturalIdMultiLoadAccess<T>byMultipleNaturalId(String entityName) Create aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the named entity type by their by natural id values, using batching.<T> NaturalIdLoadAccess<T>byNaturalId(Class<T> entityClass) Create aNaturalIdLoadAccessinstance to retrieve an instance of the given entity type by its natural id, which may be a composite natural id.<T> NaturalIdLoadAccess<T>byNaturalId(String entityName) Create aNaturalIdLoadAccessinstance to retrieve an instance of the named entity type by its natural id, which may be a composite natural id.<T> SimpleNaturalIdLoadAccess<T>bySimpleNaturalId(Class<T> entityClass) Create aSimpleNaturalIdLoadAccessinstance to retrieve an instance of the given entity type by its natural id, which must be a simple (non-composite) value.<T> SimpleNaturalIdLoadAccess<T>bySimpleNaturalId(String entityName) Create aSimpleNaturalIdLoadAccessinstance to retrieve an instance of the named entity type by its natural id, which must be a simple (non-composite) value.voidCancel the execution of the current query.voidCheck whether the session is open, and if not: mark the current transaction, if any, for rollback only, and throw anIllegalStateException.voidcheckOpen(boolean markForRollbackIfClosed) Check whether the session is open, and if not: ifmarkForRollbackIfClosed = true, mark the current transaction, if any, for rollback only, and throw anIllegalStateException.voidcheckTransactionNeededForUpdateOperation(String exceptionMessage) Check if an activeTransactionis available before performing an update operation against the database.voidclear()Completely clear the session.voidclose()End the session by releasing the JDBC connection and cleaning up.booleanCheck if the instance is a managed entity instance belonging to the current persistence context.booleanDetermine if the given entity is associated with this session.<T> RootGraphImplementor<T>createEntityGraph(Class<T> rootType) Create a new mutableEntityGraphwith only a root node.<T> RootGraph<T>createEntityGraph(Class<T> rootType, String graphName) Create a new mutable copy of the namedEntityGraph, or returnnullif there is no graph with the given name.createEntityGraph(String graphName) Create a new mutable copy of the namedEntityGraph, or returnnullif there is no graph with the given name.createMutationQuery(CriteriaDelete deleteQuery) Create aMutationQueryfrom the given delete criteria treecreateMutationQuery(CriteriaUpdate updateQuery) Create aMutationQueryfrom the given update criteria treecreateMutationQuery(String statementString) Create aMutationQueryreference for the given HQL insert, update, or delete statement.createMutationQuery(JpaCriteriaInsert insertSelect) Create aMutationQueryfrom the given insert criteria treecreateMutationQuery(JpaCriteriaInsertSelect insertSelect) Create aMutationQueryfrom the given insert-select criteria treeCreate aMutationQueryinstance for the given named insert, update, or delete HQL query.createNamedQuery(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.Create aSelectionQueryinstance for the namedNamedQuery.<R> SelectionQuery<R>createNamedSelectionQuery(String name, Class<R> resultType) Create aSelectionQueryinstance for the namedNamedQuerywith the given result type.Obtain aProcedureCallbased on a named templatecreateNativeMutationQuery(String sqlString) Create aNativeQueryinstance for the given native SQL statement.createNativeQuery(String sqlString) Create aNativeQueryinstance for the given native SQL query.createNativeQuery(String sqlString, Class resultClass) Create aNativeQueryinstance for the given native SQL query using an implicit mapping to the specified Java type.<T> NativeQueryImplementor<T>createNativeQuery(String sqlString, Class<T> resultClass, String tableAlias) Create aNativeQueryinstance for the given native SQL query using an implicit mapping to the specified Java entity type.createNativeQuery(String sqlString, String resultSetMappingName) Create aNativeQueryinstance for the given native SQL query using an explicit mapping to the specified Java type.<T> NativeQueryImplementor<T>createNativeQuery(String sqlString, String resultSetMappingName, Class<T> resultClass) Create aNativeQueryinstance for the given native SQL query using an explicit mapping to the specified Java type.createQuery(CriteriaDelete deleteQuery) Create aQueryfor the given JPACriteriaDelete.<T> QueryImplementor<T>createQuery(CriteriaQuery<T> criteriaQuery) Create aQueryfor the given JPACriteriaQuery.createQuery(CriteriaUpdate updateQuery) Create aQueryfor the given JPACriteriaUpdate.createQuery(String queryString) Create aQueryinstance for the given HQL query, or HQL insert, update, or delete statement.<T> QueryImplementor<T>createQuery(String queryString, Class<T> resultType) Create a typedQueryinstance for the given HQL query string and given query result type.<R> SelectionQuery<R>createSelectionQuery(CriteriaQuery<R> criteria) Create aSelectionQueryreference for the givenCriteriaQuery.createSelectionQuery(String hqlString) Create aSelectionQueryreference for the given HQLselectstatement.<R> SelectionQuery<R>createSelectionQuery(String hqlString, Class<R> resultType) Create aSelectionQueryinstance for the given HQL query string and given query result type.createStoredProcedureCall(String procedureName) Create aProcedureCallto a stored procedure.createStoredProcedureCall(String procedureName, Class<?>... resultClasses) Create aProcedureCallto a stored procedure with the given result set entity mappings.createStoredProcedureCall(String procedureName, String... resultSetMappings) Create aProcedureCallto a stored procedure with the given result set entity mappings.createStoredProcedureQuery(String procedureName) Create aProcedureCallto a stored procedure.createStoredProcedureQuery(String procedureName, Class... resultClasses) Create aProcedureCallto a stored procedure with the given result set entity mappings.createStoredProcedureQuery(String procedureName, String... resultSetMappings) Create aProcedureCallto a stored procedure with the given result set entity mappings.protected SessionImplementordelegate()Returns the delegate session.voidRemove a persistent instance from the datastore.voidRemove a persistent instance from the datastore.voiddelete(String entityName, Object child, boolean isCascadeDeleteEnabled, DeleteContext transientEntities) voidRemove this instance from the session cache.voiddisableFetchProfile(String name) Disable thefetch profilewith the given name in 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.voidPerform work using theConnectionunderlying by this session.voidenableFetchProfile(String name) Enable thefetch profilewith the given name in this session.enableFilter(String filterName) Enable the named filter for this current session.voidRemove 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> @Nullable TFind by primary key.<T> @Nullable Tfind(Class<T> entityClass, Object primaryKey, LockModeType lockMode) Find by primary key and lock.<T> @Nullable TFind by primary key and lock, using the specified properties.<T> @Nullable TFind by primary key, using the specified properties.voidflush()Force this session to flush.voidvoidInitiate a flush to force deletion of a re-persisted entity.voidInitiate a flush to force deletion of a re-persisted entity.generateEntityKey(Object id, EntityPersister persister) Instantiate anEntityKeywith the given id and for the entity represented by the givenEntityPersister.<T> TReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.<T> TReturn 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.Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance.Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.get(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.Get theActionQueueassociated with this session.Get the current cache mode for this session.The JPA-definedCacheRetrieveMode.The JPA-definedCacheStoreMode.The currentCacheTransactionSynchronizationassociated with this session.getContextEntityIdentifier(Object object) Return the identifier of the persistent object, or null if it is not associated with this session.getCurrentLockMode(Object object) Determine the currentLockModeof the given managed instance associated with this session.This is the implementation ofEntityManager.getDelegate().getEnabledFilter(String filterName) Retrieve a currently enabled filter by name.getEntityGraph(String graphName) Retrieve the namedEntityGraphas an immutable graph, or returnnullif there is no graph with the given name.<T> List<EntityGraph<? super T>>getEntityGraphs(Class<T> entityClass) Retrieve all namedEntityGraphs with the given type.Return the entity manager factory for the entity manager.getEntityName(Object object) Return the entity name for a persistent entity.getEntityPersister(@Nullable String entityName, Object object) Get theEntityPersisterfor the given entity instance.Get the entity instance associated with the givenEntityKey, calling theInterceptorif necessary.Get theSessionEventListenerManagerassociated with this session.Obtain anExceptionConverterfor reporting an error.The factory which created this session.intGet the maximum batch size for batch fetching associations by id in this session.Get the current JPA flush mode for this session.Get the current flush mode for this session.getIdentifier(Object object) Return the identifier value of the given entity associated with this session.Retrieves theInterceptorassociated with this session.Get the session-level JDBC batch size for the current session.Obtain theJdbcCoordinatorfor this session.Obtain theJdbcServicesfor the factory which created this session.The JDBCTimeZoneused when writing a value of typeTimeorTimestampto a JDBCPreparedStatement, or when reading from a JDBCResultSet.Get theLoadQueryInfluencersassociated with this session.Obtain access to theLobCreator.getLockMode(Object entity) Get the current lock mode for the entity instance.Return an instance ofMetamodelinterface for access to the metamodel of the persistence unit.getNamedNativeQuery(String name) Get aNativeQueryinstance for a named native SQL querygetNamedNativeQuery(String name, String resultSetMapping) Get aNativeQueryinstance for a named native SQL querygetNamedProcedureCall(String name) Obtain aProcedureCallbased on a named templategetNamedQuery(String name) Create aQueryinstance for the named query.booleanGet the persistence context for this session.Similar toSharedSessionContractImplementor.getPersistenceContext(), with two differences: this version performs better as it allows for inlining and probably better prediction, and it skips some checks of the current state of the session.intThe JDBCtype codeused to bind a null boolean value.Get the properties and hints and associated values that are in effect for the entity manager.<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.getReference(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.Returns this object, fulfilling the contract ofWrapperOptions.Get the session factory which created this session.Obtain aUUIDwhich uniquely identifies this session.Get the statistics for this session.Obtain the tenant identifier associated with this session.Obtain the tenant identifier associated with this session.Get theTransactioninstance associated with this session.Obtain the builder for TransactionCoordinator instancesguessEntityName(Object entity) Obtain an estimate of the entity name of the given entity instance, which is not involved in an association, using only theEntityNameResolver.immediateLoad(String entityName, Object id) Load an instance immediately.voidinitializeCollection(PersistentCollection<?> collection, boolean writing) Initialize the given collection (if not already initialized).instantiate(String entityName, Object id) Instantiate the entity class, initializing with the given identifier.instantiate(EntityPersister persister, Object id) Instantiate the entity class of the givenEntityPersister, initializing the new instance with the given identifier.internalLoad(String entityName, Object id, boolean eager, boolean nullable) Obtain an entity instance with the given id, without checking if it was deleted or scheduled for deletion.booleanIs auto-close at transaction completion enabled?booleanisClosed()Determines whether the session is closed.booleanCheck if the session is currently connected.booleanbooleanWill 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?booleanDetermines if this session implementsEventSource.booleanisFetchProfileEnabled(String name) Is thefetch profilewith the given name enabled in this session?booleanCheck if the session is joined to the current transaction.booleanisOpen()Check if the session is still open.booleanDetermines whether the session is open or is waiting for auto-close.booleanisReadOnly(Object entityOrProxy) Is the specified entity or proxy read-only?booleanDetermine if subselect fetching is enabled in this session.booleanDoes this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?voidJoin the currently-active JTA transaction.<T> TReturn the persistent instance of the given entity class with the given identifier, making the assumption that the instance exists in the database.<T> TReturn 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.voidRead the persistent state associated with the given identifier into the given transient instance.Return the persistent instance of the given entity class with the given identifier, making the assumption that the instance exists in the database.Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.load(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, LockModeType lockMode) Lock an entity instance that is contained in the persistence context with the specified lock mode type.voidLock an entity instance that is contained in the persistence context with the specified lock mode type and with specified properties.voidObtain the specified lock level on the given managed instance associated with this session.voidlock(Object object, LockOptions lockOptions) Obtain a lock on the given managed instance associated with this session, using the given lock options.voidObtain the specified lock level on the given managed instance associated with this session.voidlock(String entityName, Object object, LockOptions lockOptions) Cascade the lock operation to the given child entity.voidMarks current transaction, if any, for rollback only.voidmerge(String entityName, Object object, MergeContext copiedAlready) <T> TCopy 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.voidMake a transient instance persistent and mark it for later insertion in the database.voidMake 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 aQueryorProcedureCallvoidReread the state of the given managed instance associated with this session from the underlying database.voidrefresh(Object entity, LockModeType lockMode) Refresh the state of the instance from the database, overwriting changes made to the entity, if any, and lock it with respect to given lock mode type.voidRefresh the state of the instance from the database, overwriting changes made to the entity, if any, and lock it with respect to given lock mode type and with specified properties.voidRefresh the state of the instance from the database, using the specified properties, and overwriting changes made to the entity, if any.voidReread 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.voidReread 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.voidMark 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.Persist the given transient instance, first assigning a generated identifier.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).Obtain aSessionbuilder with the ability to copy certain information from this session.voidsetAutoClear(boolean enabled) Enable or disable automatic cache clearing from after transaction completion.voidSet the current cache mode for this session.voidsetCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode) Enable or disable reads from the second-level cache.voidsetCacheStoreMode(CacheStoreMode cacheStoreMode) Enable or disable writes to the second-level cache.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.voidsetFetchBatchSize(int batchSize) Set the maximum batch size for batch fetching associations by id in this session.voidsetFlushMode(FlushModeType flushModeType) Set the currentJPA flush modefor this session.voidsetHibernateFlushMode(FlushMode flushMode) Set the current flush mode for this session.voidsetJdbcBatchSize(Integer jdbcBatchSize) Set the session-level JDBC batch size.voidsetNativeJdbcParametersIgnored(boolean nativeJdbcParametersIgnored) voidsetProperty(String propertyName, Object value) Set an entity manager property or hint.voidsetReadOnly(Object entityOrProxy, boolean readOnly) Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode.voidsetSubselectFetchingEnabled(boolean enabled) Enable or disable subselect fetching in this session.booleanShould this session be automatically closed after the current transaction completes?booleanIndicates whether an active transaction should be automatically joined.voidCallback indicating recognition of entering into a transactional context whether that is explicitly via the HibernateTransactionAPI or via registration of Hibernate's JTA Synchronization impl with a JTA Transaction<T> TReturn an object of the specified type to allow access to the provider-specific API.voidUpdate the persistent instance with the identifier of the given detached instance.voidUpdate the persistent instance with the identifier of the given detached instance.booleanDetermines whether streams should be used for binding LOB values.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.resource.jdbc.spi.JdbcSessionOwner
getSqlExceptionHelperMethods inherited from interface org.hibernate.engine.jdbc.LobCreationContext
fromContextMethods inherited from interface org.hibernate.engine.spi.SessionImplementor
asSessionImplementor, isSessionImplementorMethods inherited from interface org.hibernate.engine.spi.SharedSessionContractImplementor
asStatelessSession, bestGuessEntityName, getConfiguredJdbcBatchSize, getSessionToken, getTypeConfiguration, isEnforcingFetchGraph, isStatelessSession, setEnforcingFetchGraphMethods inherited from interface org.hibernate.type.descriptor.WrapperOptions
getDialect
-
Field Details
-
delegate
-
-
Constructor Details
-
SessionDelegatorBaseImpl
-
-
Method Details
-
delegate
Returns the delegate session.- See Also:
-
execute
Description copied from interface:LobCreationContextExecute the given callback, making sure it has access to a viable JDBCConnection.- Specified by:
executein interfaceLobCreationContext- Type Parameters:
T- The Java type of the type of LOB being created. One ofBlob,Clob,NClob- Parameters:
callback- The callback to execute .- Returns:
- The LOB created by the callback.
-
getTenantIdentifier
Description copied from interface:SharedSessionContractObtain the tenant identifier associated with this session.- Specified by:
getTenantIdentifierin interfaceSharedSessionContract- Returns:
- The tenant identifier associated with this session, or
null
-
getTenantIdentifierValue
Description copied from interface:SharedSessionContractObtain the tenant identifier associated with this session.- Specified by:
getTenantIdentifierValuein interfaceSharedSessionContract- Returns:
- The tenant identifier associated with this session, or
null
-
getSessionIdentifier
Description copied from interface:SharedSessionContractImplementorObtain aUUIDwhich uniquely identifies this session.The UUID is useful mainly for logging.
- Specified by:
getSessionIdentifierin interfaceSharedSessionContractImplementor
-
getJdbcConnectionAccess
- Specified by:
getJdbcConnectionAccessin interfaceJdbcSessionOwner
-
generateEntityKey
Description copied from interface:SharedSessionContractImplementorInstantiate anEntityKeywith the given id and for the entity represented by the givenEntityPersister.- Specified by:
generateEntityKeyin interfaceSharedSessionContractImplementor- Parameters:
id- The entity idpersister- The entity persister- Returns:
- The entity key
-
getInterceptor
Description copied from interface:SharedSessionContractImplementorRetrieves theInterceptorassociated with this session.- Specified by:
getInterceptorin interfaceSharedSessionContractImplementor
-
setAutoClear
public void setAutoClear(boolean enabled) Description copied from interface:SharedSessionContractImplementorEnable or disable automatic cache clearing from after transaction completion.- Specified by:
setAutoClearin interfaceSharedSessionContractImplementor
-
isTransactionInProgress
public boolean isTransactionInProgress()Description copied from interface:SharedSessionContractImplementorDoes this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?- Specified by:
isTransactionInProgressin interfaceSharedSessionContractImplementor
-
checkTransactionNeededForUpdateOperation
Description copied from interface:SharedSessionContractImplementorCheck if an activeTransactionis available before performing an update operation against the database.If an active transaction is necessary, but no transaction is active, a
TransactionRequiredExceptionis raised.- Specified by:
checkTransactionNeededForUpdateOperationin interfaceSharedSessionContractImplementor- Parameters:
exceptionMessage- the message to use for theTransactionRequiredException
-
initializeCollection
public void initializeCollection(PersistentCollection<?> collection, boolean writing) throws HibernateException Description copied from interface:SharedSessionContractImplementorInitialize the given 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:SharedSessionContractImplementorObtain an entity instance with the given id, without checking if it was deleted or scheduled for deletion.- When
nullable = false, this method may create a new proxy or return an existing proxy; if it does not exist, an exception is thrown. - When
nullable = true, the method does not create new proxies, though it might return an existing proxy; if it does not exist, anullvalue is returned.
When
eager = true, the object is eagerly fetched from the database.- Specified by:
internalLoadin interfaceSharedSessionContractImplementor- Throws:
HibernateException
- When
-
immediateLoad
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
Description copied from interface:SharedSessionContractThe factory which created this session.- Specified by:
getFactoryin interfaceQueryProducerImplementor- Specified by:
getFactoryin interfaceSharedSessionContract- Specified by:
getFactoryin interfaceSharedSessionContractImplementor
-
getEntityPersister
public EntityPersister getEntityPersister(@Nullable String entityName, Object object) throws HibernateException Description copied from interface:SharedSessionContractImplementorGet theEntityPersisterfor the given entity instance.- Specified by:
getEntityPersisterin interfaceSharedSessionContractImplementor- Parameters:
entityName- optional entity nameobject- the entity instance- Throws:
HibernateException
-
getEntityUsingInterceptor
Description copied from interface:SharedSessionContractImplementorGet the entity instance associated with the givenEntityKey, calling theInterceptorif necessary.- Specified by:
getEntityUsingInterceptorin interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
getContextEntityIdentifier
Description copied from interface:SharedSessionContractImplementorReturn the identifier of the persistent object, or null if it is not associated with this session.- Specified by:
getContextEntityIdentifierin interfaceSharedSessionContractImplementor
-
bestGuessEntityName
Description copied from interface:SharedSessionContractImplementorObtain the best estimate of the entity name of the given entity instance, which is not involved in an association, by also considering information held in the proxy, and whether the object is already associated with this session.- Specified by:
bestGuessEntityNamein interfaceSharedSessionContractImplementor
-
guessEntityName
Description copied from interface:SharedSessionContractImplementorObtain an estimate of the entity name of the given entity instance, which is not involved in an association, using only theEntityNameResolver.- Specified by:
guessEntityNamein interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
instantiate
Description copied from interface:SharedSessionContractImplementorInstantiate the entity class, initializing with the given identifier.- Specified by:
instantiatein interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
getPersistenceContext
Description copied from interface:SharedSessionContractImplementorGet the persistence context for this session.See
SharedSessionContractImplementor.getPersistenceContextInternal()for a faster alternative.- Specified by:
getPersistenceContextin interfaceSharedSessionContractImplementor
-
getCacheMode
Description copied from interface:SessionGet the current cache mode for this session.- Specified by:
getCacheModein interfaceQueryProducerImplementor- Specified by:
getCacheModein interfaceSession- Specified by:
getCacheModein interfaceSharedSessionContractImplementor- Returns:
- the current cache mode
-
getCacheRetrieveMode
Description copied from interface:SessionThe JPA-definedCacheRetrieveMode.- Specified by:
getCacheRetrieveModein interfaceSession- See Also:
-
getCacheStoreMode
Description copied from interface:SessionThe JPA-definedCacheStoreMode.- Specified by:
getCacheStoreModein interfaceSession- See Also:
-
setCacheMode
Description copied from interface:SessionSet the current cache mode for 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
-
setCacheStoreMode
Description copied from interface:SessionEnable or disable writes to the second-level cache.- Specified by:
setCacheStoreModein interfaceSession- Parameters:
cacheStoreMode- a JPA-definedCacheStoreMode- See Also:
-
setCacheRetrieveMode
Description copied from interface:SessionEnable or disable reads from the second-level cache.- Specified by:
setCacheRetrieveModein interfaceSession- Parameters:
cacheRetrieveMode- a JPA-definedCacheRetrieveMode- See Also:
-
setCriteriaCopyTreeEnabled
public void setCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled) - Specified by:
setCriteriaCopyTreeEnabledin interfaceSharedSessionContractImplementor
-
isCriteriaCopyTreeEnabled
public boolean isCriteriaCopyTreeEnabled()- Specified by:
isCriteriaCopyTreeEnabledin interfaceSharedSessionContractImplementor
-
getNativeJdbcParametersIgnored
public boolean getNativeJdbcParametersIgnored()- Specified by:
getNativeJdbcParametersIgnoredin interfaceSharedSessionContractImplementor
-
setNativeJdbcParametersIgnored
public void setNativeJdbcParametersIgnored(boolean nativeJdbcParametersIgnored) - Specified by:
setNativeJdbcParametersIgnoredin interfaceSharedSessionContractImplementor
-
isOpen
public boolean isOpen()Description copied from interface:SharedSessionContractCheck if the session is still open.- Specified by:
isOpenin interfaceEntityManager- 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:SharedSessionContractImplementorCheck whether the session is open, and if not:- if
markForRollbackIfClosed = true, mark the current transaction, if any, for rollback only, and - throw an
IllegalStateException. (JPA specifies this exception type.)
- Specified by:
checkOpenin interfaceSharedSessionContractImplementor
- if
-
markForRollbackOnly
public void markForRollbackOnly()Description copied from interface:SharedSessionContractImplementorMarks current transaction, if any, for rollback only.- Specified by:
markForRollbackOnlyin interfaceSharedSessionContractImplementor
-
getFlushMode
Description copied from interface:SessionGet the current JPA flush mode for this session.- Specified by:
getFlushModein interfaceEntityManager- Specified by:
getFlushModein interfaceSession- Specified by:
getFlushModein interfaceSharedSessionContractImplementor- Returns:
- the
FlushModeTypecurrently in effect
-
setFlushMode
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 interfaceEntityManager- Specified by:
setFlushModein interfaceSession- Parameters:
flushModeType- the newFlushModeType- See Also:
-
setHibernateFlushMode
Description copied from interface:SessionSet the current flush mode for 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 mode is sometimes unnecessarily aggressive. For a logically "read only" session, it's reasonable to set the session's flush mode to
FlushMode.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
Description copied from interface:SessionGet the current flush mode for this session.- Specified by:
getHibernateFlushModein interfaceQueryProducerImplementor- Specified by:
getHibernateFlushModein interfaceSession- Specified by:
getHibernateFlushModein interfaceSharedSessionContractImplementor- Returns:
- the
FlushModecurrently in effect
-
lock
Description copied from interface:EntityManagerLock an entity instance that is contained in the persistence context with the specified lock mode type.If a pessimistic lock mode type is specified and the entity contains a version attribute, the persistence provider must also perform optimistic version checks when obtaining the database lock. If these checks fail, the
OptimisticLockExceptionwill be thrown.If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
- the
PessimisticLockExceptionwill be thrown if the database locking failure causes transaction-level rollback - the
LockTimeoutExceptionwill be thrown if the database locking failure causes only statement-level rollback
- Specified by:
lockin interfaceEntityManager- Parameters:
entity- entity instancelockMode- lock mode
- the
-
lock
Description copied from interface:EntityManagerLock an entity instance that is contained in the persistence context with the specified lock mode type and with specified properties.If a pessimistic lock mode type is specified and the entity contains a version attribute, the persistence provider must also perform optimistic version checks when obtaining the database lock. If these checks fail, the
OptimisticLockExceptionwill be thrown.If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
- the
PessimisticLockExceptionwill be thrown if the database locking failure causes transaction-level rollback - the
LockTimeoutExceptionwill be thrown if the database locking failure causes only statement-level rollback
If a vendor-specific property or hint is not recognized, it is silently ignored.
Portable applications should not rely on the standard timeout hint. Depending on the database in use and the locking mechanisms used by the provider, the hint may or may not be observed.
- Specified by:
lockin interfaceEntityManager- Parameters:
entity- entity instancelockMode- lock modeproperties- standard and vendor-specific properties and hints
- the
-
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 current 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 interfaceEntityManager- Specified by:
flushin interfaceSession- Specified by:
flushin interfaceSharedSessionContractImplementor
-
isEventSource
public boolean isEventSource()Description copied from interface:SharedSessionContractImplementorDetermines if this session implementsEventSource.Only stateful session are sources of events. If this object is a stateless session, this method return
false.- Specified by:
isEventSourcein interfaceSharedSessionContractImplementor
-
asEventSource
Description copied from interface:SharedSessionContractImplementorCast this session toEventSourceif possible.Only stateful session are sources of events. If this object is a stateless session, this method throws.
- Specified by:
asEventSourcein interfaceSharedSessionContractImplementor
-
afterScrollOperation
public void afterScrollOperation()Description copied from interface:SharedSessionContractImplementorCalled after each operation on aScrollableResults, providing an opportunity for a stateless session to clear its temporary persistence context. For a stateful session, this method does nothing.- Specified by:
afterScrollOperationin interfaceSharedSessionContractImplementor
-
getTransactionCoordinator
Description copied from interface:JdbcSessionOwnerObtain the builder for TransactionCoordinator instances- Specified by:
getTransactionCoordinatorin interfaceJdbcSessionOwner- Returns:
- The TransactionCoordinatorBuilder
-
getJdbcCoordinator
Description copied from interface:SharedSessionContractImplementorObtain theJdbcCoordinatorfor this session.- Specified by:
getJdbcCoordinatorin interfaceSharedSessionContractImplementor
-
getJdbcServices
Description copied from interface:SharedSessionContractImplementorObtain theJdbcServicesfor the factory which created this session.- Specified by:
getJdbcServicesin interfaceSharedSessionContractImplementor
-
getJdbcSessionContext
- Specified by:
getJdbcSessionContextin interfaceJdbcSessionOwner
-
isClosed
public boolean isClosed()Description copied from interface:SharedSessionContractImplementorDetermines whether the session is closed.- Specified by:
isClosedin interfaceSharedSessionContractImplementor- Returns:
trueif the session is closed;falseotherwise.
-
checkOpen
public void checkOpen()Description copied from interface:SharedSessionContractImplementorCheck whether the session is open, and if not:- mark the current transaction, if any, for rollback only, and
- throw an
IllegalStateException. (JPA specifies this exception type.)
- Specified by:
checkOpenin interfaceSharedSessionContractImplementor
-
isOpenOrWaitingForAutoClose
public boolean isOpenOrWaitingForAutoClose()Description copied from interface:SharedSessionContractImplementorDetermines whether the session is open or is waiting for auto-close.- Specified by:
isOpenOrWaitingForAutoClosein interfaceSharedSessionContractImplementor- Returns:
trueif the session is closed, or if it's waiting for auto-close;falseotherwise.
-
shouldAutoClose
public boolean shouldAutoClose()Description copied from interface:SharedSessionContractImplementorShould this session be automatically closed after the current transaction completes?- Specified by:
shouldAutoClosein interfaceSharedSessionContractImplementor
-
isAutoCloseSessionEnabled
public boolean isAutoCloseSessionEnabled()Description copied from interface:SharedSessionContractImplementorIs auto-close at transaction completion enabled?- Specified by:
isAutoCloseSessionEnabledin interfaceSharedSessionContractImplementor- See Also:
-
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
Description copied from interface:SharedSessionContractImplementorGet theLoadQueryInfluencersassociated with this session.- Specified by:
getLoadQueryInfluencersin interfaceSharedSessionContractImplementor- Returns:
- the
LoadQueryInfluencersassociated with this session; should never be null.
-
getExceptionConverter
Description copied from interface:SharedSessionContractImplementorObtain anExceptionConverterfor reporting an error.The converter associated to a session might be lazily initialized, so only invoke this getter when there's an actual need to use it.
- Specified by:
getExceptionConverterin interfaceSharedSessionContractImplementor- Returns:
- the ExceptionConverter for this Session.
-
getPersistenceContextInternal
Description copied from interface:SharedSessionContractImplementorSimilar toSharedSessionContractImplementor.getPersistenceContext(), with two differences:- this version performs better as it allows for inlining and probably better prediction, and
- it skips some checks of the current state of the session.
- Specified by:
getPersistenceContextInternalin interfaceSharedSessionContractImplementor- Returns:
- the
PersistenceContextassociated to this session.
-
autoFlushIfRequired
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
-
autoFlushIfRequired
public boolean autoFlushIfRequired(Set<String> querySpaces, boolean skipPreFlush) throws HibernateException - Specified by:
autoFlushIfRequiredin interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
autoPreFlush
public void autoPreFlush()- Specified by:
autoPreFlushin interfaceSharedSessionContractImplementor
-
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, making sure that the connection has been committed (if it is not in autocommit mode), and finally run the after completion processing.- Specified by:
afterOperationin interfaceSharedSessionContractImplementor- Parameters:
success-trueif the operation a success
-
getEventListenerManager
Description copied from interface:SharedSessionContractImplementorGet theSessionEventListenerManagerassociated with this session.- Specified by:
getEventListenerManagerin interfaceSharedSessionContractImplementor
-
accessTransaction
Description copied from interface:SharedSessionContractImplementorRetrieves the currentTransaction, or creates a new transaction if there is no transaction active.This method is primarily for internal or integrator use.
- Specified by:
accessTransactionin interfaceSharedSessionContractImplementor- Returns:
- the
Transaction
-
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:
-
getTransaction
Description copied from interface:SharedSessionContractGet theTransactioninstance associated with this session.- Specified by:
getTransactionin interfaceEntityManager- Specified by:
getTransactionin interfaceSharedSessionContract- Returns:
- a Transaction instance
- See Also:
-
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
Description copied from interface:SharedSessionContractImplementorThe currentCacheTransactionSynchronizationassociated with this session. This may benullif the session is not currently associated with an active transaction.- Specified by:
getCacheTransactionSynchronizationin interfaceSharedSessionContractImplementor
-
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
Description copied from interface:EntityManagerReturn the entity manager factory for the entity manager.- Specified by:
getEntityManagerFactoryin interfaceEntityManager- Returns:
- EntityManagerFactory instance
-
getCriteriaBuilder
Description copied from interface:SharedSessionContract- Specified by:
getCriteriaBuilderin interfaceEntityManager- Specified by:
getCriteriaBuilderin interfaceSharedSessionContract- Returns:
- an instance of
HibernateCriteriaBuilder - See Also:
-
getMetamodel
Description copied from interface:EntityManagerReturn an instance ofMetamodelinterface for access to the metamodel of the persistence unit.- Specified by:
getMetamodelin interfaceEntityManager- Returns:
- Metamodel instance
-
createEntityGraph
Description copied from interface:SharedSessionContractCreate a new mutableEntityGraphwith only a root node.- Specified by:
createEntityGraphin interfaceEntityManager- Specified by:
createEntityGraphin interfaceSession- Specified by:
createEntityGraphin interfaceSessionImplementor- Specified by:
createEntityGraphin interfaceSharedSessionContract- Parameters:
rootType- the root entity class of the graph- Returns:
- entity graph
-
createEntityGraph
Description copied from interface:SharedSessionContractCreate a new mutable copy of the namedEntityGraph, or returnnullif there is no graph with the given name.- Specified by:
createEntityGraphin interfaceEntityManager- Specified by:
createEntityGraphin interfaceSession- Specified by:
createEntityGraphin interfaceSessionImplementor- Specified by:
createEntityGraphin interfaceSharedSessionContract- Parameters:
graphName- the name of the graph- Returns:
- entity graph
- See Also:
-
createEntityGraph
Description copied from interface:SharedSessionContractCreate a new mutable copy of the namedEntityGraph, or returnnullif there is no graph with the given name.- Specified by:
createEntityGraphin interfaceSharedSessionContract- Parameters:
rootType- the root entity class of the graphgraphName- the name of the graph- See Also:
-
getEntityGraph
Description copied from interface:SharedSessionContractRetrieve the namedEntityGraphas an immutable graph, or returnnullif there is no graph with the given name.- Specified by:
getEntityGraphin interfaceEntityManager- Specified by:
getEntityGraphin interfaceSession- Specified by:
getEntityGraphin interfaceSessionImplementor- Specified by:
getEntityGraphin interfaceSharedSessionContract- Parameters:
graphName- the name of the graph- Returns:
- named entity graph
- See Also:
-
getEntityGraphs
Description copied from interface:SharedSessionContractRetrieve all namedEntityGraphs with the given type.- Specified by:
getEntityGraphsin interfaceEntityManager- Specified by:
getEntityGraphsin interfaceSession- Specified by:
getEntityGraphsin interfaceSharedSessionContract- Parameters:
entityClass- entity class- Returns:
- list of all entity graphs defined for the entity
- See Also:
-
createMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given update criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer- Specified by:
createMutationQueryin interfaceQueryProducerImplementor
-
createMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given delete criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer- Specified by:
createMutationQueryin interfaceQueryProducerImplementor
-
createMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given insert-select criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer
-
createMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given insert criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer
-
createQuery
Description copied from interface:QueryProducerCreate aQueryfor the given JPACriteriaQuery.- Specified by:
createQueryin interfaceEntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor- Specified by:
createQueryin interfaceSession- Parameters:
criteriaQuery- a criteria query object- Returns:
- the new query instance
-
createQuery
Description copied from interface:SessionCreate aQueryfor the given JPACriteriaUpdate.- Specified by:
createQueryin interfaceEntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor- Specified by:
createQueryin interfaceSession- Parameters:
updateQuery- a criteria update query object- Returns:
- the new query instance
-
createQuery
Description copied from interface:SessionCreate aQueryfor the given JPACriteriaDelete.- Specified by:
createQueryin interfaceEntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceQueryProducerImplementor- Specified by:
createQueryin interfaceSession- Parameters:
deleteQuery- a criteria delete query object- Returns:
- the new query instance
-
getNamedQuery
Description copied from interface:QueryProducerCreate aQueryinstance for the named query.- Specified by:
getNamedQueryin interfaceQueryProducer- Specified by:
getNamedQueryin interfaceQueryProducerImplementor- Parameters:
name- the name of a predefined named query- Returns:
- The
Queryinstance for manipulation and execution
-
getNamedNativeQuery
Description copied from interface:QueryProducerGet aNativeQueryinstance for a named native SQL query- Specified by:
getNamedNativeQueryin interfaceQueryProducer- Specified by:
getNamedNativeQueryin interfaceQueryProducerImplementor- Parameters:
name- The name of the predefined query- Returns:
- The
NativeQueryinstance for manipulation and execution
-
getNamedNativeQuery
Description copied from interface:QueryProducerGet aNativeQueryinstance for a named native SQL query- Specified by:
getNamedNativeQueryin interfaceQueryProducer- Specified by:
getNamedNativeQueryin interfaceQueryProducerImplementor- Parameters:
name- The name of the predefined query- Returns:
- The
NativeQueryinstance for manipulation and execution
-
createQuery
Description copied from interface:QueryProducerCreate aQueryinstance for the given HQL query, or HQL insert, update, or delete statement.If a query has no explicit
selectlist, the select list is inferred:- if there is exactly one root entity in the
fromclause, then that root entity is the only element of the select list, or - otherwise, if there are multiple root entities in the
fromclause, then the select list contains every root entity and every non-fetchjoined entity.
- Specified by:
createQueryin interfaceEntityManager- 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:
- if there is exactly one root entity in the
-
createSelectionQuery
Description copied from interface:QueryProducerCreate aSelectionQueryreference for the given HQLselectstatement.If the statement has no explicit
selectlist, the select list is inferred:- if there is exactly one root entity in the
fromclause, then that root entity is the only element of the select list, or - otherwise, if there are multiple root entities in the
fromclause, then the select list contains every root entity and every non-fetchjoined entity.
- Specified by:
createSelectionQueryin interfaceQueryProducer
- if there is exactly one root entity in the
-
createSelectionQuery
Description copied from interface:QueryProducerCreate aSelectionQueryinstance for the given HQL query string and given query result type.- If the query has a single item in the
selectlist, then the select item must be assignable to the given result type. - Otherwise, if there are multiple select items, then the
select items will be packaged into an instance of the
result type. The result type must have an appropriate
constructor with parameter types matching the select items,
or it must be one of the types
Object[],List,Map, orTuple.
If a query has no explicit
selectlist, the select list is inferred from the given query result type:- if the result type is an entity type, the query must have
exactly one root entity in the
fromclause, it must be assignable to the result type, and the inferred select list will contain just that entity, or - otherwise, the select list contains every root entity and
every non-
fetchjoined entity, and each query result will be packaged into an instance of the result type, just as specified above.
The returned
Querymay be executed by callingQuery.getResultList()orQuery.getSingleResult().- Specified by:
createSelectionQueryin interfaceQueryProducer- Parameters:
hqlString- The HQL query as a stringresultType- TheClassobject representing the query result type- See Also:
- If the query has a single item in the
-
createSelectionQuery
Description copied from interface:QueryProducerCreate aSelectionQueryreference for the givenCriteriaQuery.- Specified by:
createSelectionQueryin interfaceQueryProducer- See Also:
-
createQuery
Description copied from interface:QueryProducerCreate a typedQueryinstance for the given HQL query string and given query result type.- If the query has a single item in the
selectlist, then the select item must be assignable to the given result type. - Otherwise, if there are multiple select items, then the
select items will be packaged into an instance of the
result type. The result type must have an appropriate
constructor with parameter types matching the select items,
or it must be one of the types
Object[],List,Map, orTuple.
If a query has no explicit
selectlist, the select list is inferred from the given query result type:- if the result type is an entity type, the query must have
exactly one root entity in the
fromclause, it must be assignable to the result type, and the inferred select list will contain just that entity, or - otherwise, the select list contains every root entity and
every non-
fetchjoined entity, and each query result will be packaged into an instance of the result type, just as specified above.
The returned
Querymay be executed by callingQuery.getResultList()orQuery.getSingleResult().- Specified by:
createQueryin interfaceEntityManager- 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
Queryinstance for manipulation and execution - See Also:
- If the query has a single item in the
-
createNamedQuery
Description copied from interface:QueryProducerCreate a typedQueryinstance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQueryin interfaceEntityManager- Specified by:
createNamedQueryin interfaceQueryProducer- Specified by:
createNamedQueryin interfaceQueryProducerImplementor- Specified by:
createNamedQueryin interfaceSession- Parameters:
name- the name of a predefined named query- Returns:
- The
Queryinstance for manipulation and execution - See Also:
-
createNamedQuery
Description copied from interface:QueryProducerCreate a typedQueryinstance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQueryin interfaceEntityManager- 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:
-
createNamedSelectionQuery
Description copied from interface:QueryProducerCreate aSelectionQueryinstance for the namedNamedQuery.- Specified by:
createNamedSelectionQueryin interfaceQueryProducer
-
createNamedSelectionQuery
Description copied from interface:QueryProducerCreate aSelectionQueryinstance for the namedNamedQuerywith the given result type.- Specified by:
createNamedSelectionQueryin interfaceQueryProducer
-
createNativeQuery
Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query.- Specified by:
createNativeQueryin interfaceEntityManager- Specified by:
createNativeQueryin interfaceQueryProducer- Specified by:
createNativeQueryin interfaceQueryProducerImplementor- Parameters:
sqlString- a native SQL query string- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
-
createNativeQuery
Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query using an implicit mapping to the specified Java type.- If the given class is an entity class, this method is equivalent
to
createNativeQuery(sqlString).addEntity(resultClass). - If the given class has a registered
JavaType, then the query must return a result set with a single column whoseJdbcTypeis compatible with thatJavaType. - Otherwise, the select items will be packaged into an instance of
the result type. The result type must have an appropriate
constructor with parameter types matching the select items, or it
must be one of the types
Object[],List,Map, orTuple.
- Specified by:
createNativeQueryin interfaceEntityManager- Specified by:
createNativeQueryin interfaceQueryProducer- Specified by:
createNativeQueryin interfaceQueryProducerImplementor- Parameters:
sqlString- The native (SQL) query stringresultClass- The Java type to map results to- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
- If the given class is an entity class, this method is equivalent
to
-
createNativeQuery
public <T> NativeQueryImplementor<T> createNativeQuery(String sqlString, Class<T> resultClass, String tableAlias) Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query using an implicit mapping to the specified Java entity type.The given class must be an entity class. This method is equivalent to
createNativeQuery(sqlString).addEntity(tableAlias, resultClass).- Specified by:
createNativeQueryin interfaceQueryProducer- Specified by:
createNativeQueryin interfaceQueryProducerImplementor- Parameters:
sqlString- Native (SQL) query stringresultClass- The Java entity class to map results totableAlias- The table alias for columns in the result set- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
-
createNativeQuery
Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query using an explicit mapping to the specified Java type.The given result set mapping name must identify a mapping defined by a
SqlResultSetMappingannotation.- Specified by:
createNativeQueryin interfaceEntityManager- 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:
-
createNativeQuery
public <T> NativeQueryImplementor<T> createNativeQuery(String sqlString, String resultSetMappingName, Class<T> resultClass) Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query using an explicit mapping to the specified Java type.The given result set mapping name must identify a mapping defined by a
SqlResultSetMappingannotation.- Specified by:
createNativeQueryin interfaceQueryProducer- Specified by:
createNativeQueryin interfaceQueryProducerImplementor- Parameters:
sqlString- The native (SQL) query stringresultSetMappingName- The explicit result mapping name- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
-
createMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryreference for the given HQL insert, update, or delete statement.- Specified by:
createMutationQueryin interfaceQueryProducer- Specified by:
createMutationQueryin interfaceQueryProducerImplementor
-
createNamedMutationQuery
Description copied from interface:QueryProducerCreate aMutationQueryinstance for the given named insert, update, or delete HQL query. The named query might be defined as HQL) or native-SQL.- Specified by:
createNamedMutationQueryin interfaceQueryProducer- Specified by:
createNamedMutationQueryin interfaceQueryProducerImplementor
-
createNativeMutationQuery
Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL statement.- Specified by:
createNativeMutationQueryin interfaceQueryProducer- Specified by:
createNativeMutationQueryin interfaceQueryProducerImplementor- Parameters:
sqlString- a native SQL statement string- Returns:
- The NativeQuery instance for manipulation and execution
-
createNamedStoredProcedureQuery
Description copied from interface:SharedSessionContractObtain aProcedureCallbased on a named template- Specified by:
createNamedStoredProcedureQueryin interfaceEntityManager- Specified by:
createNamedStoredProcedureQueryin interfaceSharedSessionContract- Parameters:
name- The name given to the template- Returns:
- The ProcedureCall
- See Also:
-
createStoredProcedureQuery
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure.- Specified by:
createStoredProcedureQueryin interfaceEntityManager- Specified by:
createStoredProcedureQueryin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureQueryin interfaceEntityManager- Specified by:
createStoredProcedureQueryin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.resultClasses- The entity(s) to map the result on to.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureQueryin interfaceEntityManager- 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()Description copied from interface:SharedSessionContractJoin the currently-active JTA transaction.- Specified by:
joinTransactionin interfaceEntityManager- Specified by:
joinTransactionin interfaceSharedSessionContract- See Also:
-
isJoinedToTransaction
public boolean isJoinedToTransaction()Description copied from interface:SharedSessionContractCheck if the session is joined to the current transaction.- Specified by:
isJoinedToTransactionin interfaceEntityManager- Specified by:
isJoinedToTransactionin interfaceSharedSessionContract- Returns:
- boolean
- See Also:
-
unwrap
Description copied from interface:EntityManagerReturn an object of the specified type to allow access to the provider-specific API. If the provider'sEntityManagerimplementation does not support the specified class, thePersistenceExceptionis thrown.- Specified by:
unwrapin interfaceEntityManager- Parameters:
cls- the class of the object to be returned. This is normally either the underlyingEntityManagerimplementation class or an interface that it implements.- Returns:
- an instance of the specified class
-
getDelegate
This is the implementation ofEntityManager.getDelegate(). It returns this object and not what we call the "delegate" session here. To get the delegate session, usedelegate()instead.- Specified by:
getDelegatein interfaceEntityManager- Returns:
- underlying provider object for EntityManager
- See Also:
-
getNamedProcedureCall
Description copied from interface:SharedSessionContractObtain aProcedureCallbased on a named template- Specified by:
getNamedProcedureCallin interfaceSharedSessionContract- Parameters:
name- The name given to the template- Returns:
- The ProcedureCall
- See Also:
-
createStoredProcedureCall
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure.- Specified by:
createStoredProcedureCallin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureCallin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.resultClasses- The entity(s) to map the result on to.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureCallin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.resultSetMappings- The explicit result set mapping(s) to use for mapping the results- Returns:
- The representation of the procedure call.
-
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
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:
-
close
Description copied from interface:SharedSessionContractEnd the session by releasing the JDBC connection and cleaning up.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceEntityManager- Specified by:
closein interfaceSharedSessionContract- Throws:
HibernateException- Indicates problems cleaning up.
-
cancelQuery
Description 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
Description 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:
-
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:
-
getIdentifier
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
Description copied from interface:SessionDetermine if the given entity is associated with this session. -
contains
Description copied from interface:EntityManagerCheck if the instance is a managed entity instance belonging to the current persistence context.- Specified by:
containsin interfaceEntityManager- Parameters:
object- entity instance- Returns:
- boolean indicating if entity is in persistence context
-
getLockMode
Description copied from interface:EntityManagerGet the current lock mode for the entity instance.- Specified by:
getLockModein interfaceEntityManager- Parameters:
entity- entity instance- Returns:
- lock mode
-
setProperty
Description copied from interface:EntityManagerSet an entity manager property or hint. If a vendor-specific property or hint is not recognized, it is silently ignored.- Specified by:
setPropertyin interfaceEntityManager- Parameters:
propertyName- name of property or hintvalue- value for property or hint
-
getProperties
Description copied from interface:EntityManagerGet the properties and hints and associated values that are in effect for the entity manager. Changing the contents of the map does not change the configuration in effect.- Specified by:
getPropertiesin interfaceEntityManager- Returns:
- map of properties and hints in effect for entity manager
-
evict
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
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 of
Session.load(Class, Object, LockOptions). -
load
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
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 of
Session.load(String, Object, LockOptions). -
load
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
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
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
Description copied from interface:SessionRead the persistent state associated with the given identifier into the given transient instance. -
replicate
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
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
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
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
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 with
CascadeType.SAVE_UPDATE.- Specified by:
saveOrUpdatein interfaceSession- Parameters:
object- a transient or detached instance containing new or updated state- See Also:
-
saveOrUpdate
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 with
CascadeType.SAVE_UPDATE.- Specified by:
saveOrUpdatein interfaceSession- Parameters:
entityName- the entity nameobject- a transient or detached instance containing new or updated state- See Also:
-
update
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
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.- Specified by:
mergein interfaceEntityManager- Specified by:
mergein interfaceSession- Parameters:
object- a detached instance with state to be copied- Returns:
- an updated persistent instance
-
merge
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
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 an entity 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.- Specified by:
persistin interfaceEntityManager- Specified by:
persistin interfaceSession- Parameters:
object- a transient instance to be made persistent
-
remove
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.- Specified by:
removein interfaceEntityManager- Specified by:
removein interfaceSession- Parameters:
entity- the managed persistent instance to remove
-
find
Description copied from interface:EntityManagerFind by primary key. Search for an entity of the specified class and primary key. If the entity instance is contained in the persistence context, it is returned from there.- Specified by:
findin interfaceEntityManager- Parameters:
entityClass- entity classprimaryKey- primary key- Returns:
- the found entity instance or null if the entity does not exist
-
find
Description copied from interface:EntityManagerFind by primary key, using the specified properties. Search for an entity of the specified class and primary key. If the entity instance is contained in the persistence context, it is returned from there. If a vendor-specific property or hint is not recognized, it is silently ignored.- Specified by:
findin interfaceEntityManager- Parameters:
entityClass- entity classprimaryKey- primary keyproperties- standard and vendor-specific properties and hints- Returns:
- the found entity instance or null if the entity does not exist
-
find
Description copied from interface:EntityManagerFind by primary key and lock. Search for an entity of the specified class and primary key and lock it with respect to the specified lock type. If the entity instance is contained in the persistence context, it is returned from there, and the effect of this method is the same as if the lock method had been called on the entity.If the entity is found within the persistence context and the lock mode type is pessimistic and the entity has a version attribute, the persistence provider must perform optimistic version checks when obtaining the database lock. If these checks fail, the
OptimisticLockExceptionwill be thrown.If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
- the
PessimisticLockExceptionwill be thrown if the database locking failure causes transaction-level rollback - the
LockTimeoutExceptionwill be thrown if the database locking failure causes only statement-level rollback
- Specified by:
findin interfaceEntityManager- Parameters:
entityClass- entity classprimaryKey- primary keylockMode- lock mode- Returns:
- the found entity instance or null if the entity does not exist
- the
-
find
public <T> @Nullable T find(Class<T> entityClass, Object primaryKey, LockModeType lockMode, Map<String, Object> properties) Description copied from interface:EntityManagerFind by primary key and lock, using the specified properties. Search for an entity of the specified class and primary key and lock it with respect to the specified lock type. If the entity instance is contained in the persistence context, it is returned from there.If the entity is found within the persistence context and the lock mode type is pessimistic and the entity has a version attribute, the persistence provider must perform optimistic version checks when obtaining the database lock. If these checks fail, the
OptimisticLockExceptionwill be thrown.If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
- the
PessimisticLockExceptionwill be thrown if the database locking failure causes transaction-level rollback - the
LockTimeoutExceptionwill be thrown if the database locking failure causes only statement-level rollback
If a vendor-specific property or hint is not recognized, it is silently ignored.
Portable applications should not rely on the standard timeout hint. Depending on the database in use and the locking mechanisms used by the provider, the hint may or may not be observed.
- Specified by:
findin interfaceEntityManager- Parameters:
entityClass- entity classprimaryKey- primary keylockMode- lock modeproperties- standard and vendor-specific properties and hints- Returns:
- the found entity instance or null if the entity does not exist
- the
-
getReference
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.It's sometimes necessary to narrow a reference returned by
getReference()to a subtype of the given entity type. A direct Java typecast should never be used in this situation. Instead, the methodHibernate.unproxy(Object, Class)is the recommended way to narrow the type of a proxy object. Alternatively, a new reference may be obtained by simply callinggetReference()again, passing the subtype. Either way, the narrowed reference will usually not be identical to the original reference, when the references are compared using the==operator.- Specified by:
getReferencein interfaceEntityManager- 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
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
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
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
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
Description copied from interface:SessionObtain the specified lock level on the given managed instance associated with this session. This operation may be used to:- perform a version check on an entity read from the second-level cache
by requesting
LockMode.READ, - schedule a version check at transaction commit by requesting
LockMode.OPTIMISTIC, - schedule a version increment at transaction commit by requesting
LockMode.OPTIMISTIC_FORCE_INCREMENT - upgrade to a pessimistic lock with
LockMode.PESSIMISTIC_READorLockMode.PESSIMISTIC_WRITE, or - immediately increment the version of the given instance by requesting
LockMode.PESSIMISTIC_FORCE_INCREMENT.
If the requested lock mode is already held on the given entity, this operation has no effect.
This operation cascades to associated instances if the association is mapped with
CascadeType.LOCK.The modes
LockMode.WRITEandLockMode.UPGRADE_SKIPLOCKEDare not legal arguments tolock(). - perform a version check on an entity read from the second-level cache
by requesting
-
lock
Description copied from interface:SessionObtain the specified lock level on the given managed instance associated 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).
This operation cascades to associated instances if the association is mapped with
CascadeType.LOCK. - perform a version check with
-
lock
Description copied from interface:SessionImplementorCascade the lock operation to the given child entity.- Specified by:
lockin interfaceSessionImplementor
-
lock
Description copied from interface:SessionObtain a lock on the given managed instance associated with this session, using the given lock options.This operation cascades to associated instances if the association is mapped with
CascadeType.LOCK. -
buildLockRequest
Deprecated.Description copied from interface:SessionBuild a new lock request that specifies:- the
LockModeto use, - the pessimistic lock timeout, and
- the scope that is, whether the lock extends to rows of owned collections.
Timeout and scope are ignored if the specified
LockModerepresents a flavor of optimistic locking.Call
Session.LockRequest.lock(Object)to actually obtain the requested lock on a managed entity instance.- Specified by:
buildLockRequestin interfaceSession- Parameters:
lockOptions- contains the lock level- Returns:
- a
Session.LockRequestthat can be used to lock any given object.
- the
-
refresh
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, or
- after inserting a
BloborClob.
This operation cascades to associated instances if the association is mapped with
CascadeType.REFRESH.This operation requests
LockMode.READ. To obtain a stronger lock, callSession.refresh(Object, LockMode).- Specified by:
refreshin interfaceEntityManager- Specified by:
refreshin interfaceSession- Parameters:
object- a persistent instance associated with this session
-
refresh
Description copied from interface:EntityManagerRefresh the state of the instance from the database, using the specified properties, and overwriting changes made to the entity, if any.If a vendor-specific property or hint is not recognized, it is silently ignored.
- Specified by:
refreshin interfaceEntityManager- Parameters:
entity- entity instanceproperties- standard and vendor-specific properties and hints
-
refresh
Description copied from interface:EntityManagerRefresh the state of the instance from the database, overwriting changes made to the entity, if any, and lock it with respect to given lock mode type.If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
- the
PessimisticLockExceptionwill be thrown if the database locking failure causes transaction-level rollback - the
LockTimeoutExceptionwill be thrown if the database locking failure causes only statement-level rollback.
- Specified by:
refreshin interfaceEntityManager- Parameters:
entity- entity instancelockMode- lock mode
- the
-
refresh
Description copied from interface:EntityManagerRefresh the state of the instance from the database, overwriting changes made to the entity, if any, and lock it with respect to given lock mode type and with specified properties.If the lock mode type is pessimistic and the entity instance is found but cannot be locked:
- the
PessimisticLockExceptionwill be thrown if the database locking failure causes transaction-level rollback - the
LockTimeoutExceptionwill be thrown if the database locking failure causes only statement-level rollback
If a vendor-specific property or hint is not recognized, it is silently ignored.
Portable applications should not rely on the standard timeout hint. Depending on the database in use and the locking mechanisms used by the provider, the hint may or may not be observed.
- Specified by:
refreshin interfaceEntityManager- Parameters:
entity- entity instancelockMode- lock modeproperties- standard and vendor-specific properties and hints
- the
-
refresh
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, or
- after inserting a
BloborClob.
This operation cascades to associated instances if the association is mapped with
CascadeType.REFRESH. -
refresh
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) -
refresh
Description copied from interface:SessionReread the state of the given managed instance from the underlying database, obtaining the givenLockMode. -
refresh
Description copied from interface:SessionReread the state of the given managed instance from the underlying database, obtaining the givenLockMode. -
getCurrentLockMode
Description copied from interface:SessionDetermine the currentLockModeof the given managed instance associated with this session.- Specified by:
getCurrentLockModein interfaceSession- Parameters:
object- a persistent instance associated with this session- 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.- Specified by:
clearin interfaceEntityManager- Specified by:
clearin interfaceSession
-
detach
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.- Specified by:
detachin interfaceEntityManager- Specified by:
detachin interfaceSession- Parameters:
entity- the managed instance to detach
-
get
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).The object returned by
get()orfind()is either an unproxied instance of the given entity class, of a fully-fetched proxy object.This operation requests
LockMode.NONE, that is, no lock, allowing the object to be retrieved from the cache without the cost of database access. However, if it is necessary to read the state from the database, the object will be returned with the lock modeLockMode.READ.To bypass the second-level cache, and ensure that the state is read from the database, either:
- call
Session.get(Class, Object, LockMode)with the explicit lock modeLockMode.READ, or - set the cache mode to
CacheMode.IGNOREbefore calling this method.
- call
-
get
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). -
get
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
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
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(String, Object, LockOptions) -
get
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
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
Description copied from interface:SessionCreate anIdentifierLoadAccessinstance to retrieve an instance of the named entity type by its primary key.- Specified by:
byIdin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- an instance of
IdentifierLoadAccessfor executing the lookup
-
byMultipleIds
Description copied from interface:SessionCreate aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the given entity type by their primary key values, using batching.- Specified by:
byMultipleIdsin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- an instance of
MultiIdentifierLoadAccessfor executing the lookup
-
byMultipleIds
Description copied from interface:SessionCreate aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the named entity type by their primary key values, using batching.- Specified by:
byMultipleIdsin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- an instance of
MultiIdentifierLoadAccessfor executing the lookup
-
byId
Description copied from interface:SessionCreate anIdentifierLoadAccessinstance to retrieve an instance of the given entity type by its primary key.- Specified by:
byIdin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- an instance of
IdentifierLoadAccessfor executing the lookup
-
byNaturalId
Description copied from interface:SessionCreate aNaturalIdLoadAccessinstance to retrieve an instance of the named entity type by its natural id, which may be a composite natural id. The entity must have at least one attribute annotatedNaturalId.- Specified by:
byNaturalIdin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- an instance of
NaturalIdLoadAccessfor executing the lookup
-
byNaturalId
Description copied from interface:SessionCreate aNaturalIdLoadAccessinstance to retrieve an instance of the given entity type by its natural id, which may be a composite natural id. The entity must have at least one attribute annotatedNaturalId.- Specified by:
byNaturalIdin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- an instance of
NaturalIdLoadAccessfor executing the lookup
-
bySimpleNaturalId
Description copied from interface:SessionCreate aSimpleNaturalIdLoadAccessinstance to retrieve an instance of the named entity type by its natural id, which must be a simple (non-composite) value. The entity must have exactly one attribute annotatedNaturalId.- Specified by:
bySimpleNaturalIdin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- an instance of
SimpleNaturalIdLoadAccessfor executing the lookup
-
bySimpleNaturalId
Description copied from interface:SessionCreate aSimpleNaturalIdLoadAccessinstance to retrieve an instance of the given entity type by its natural id, which must be a simple (non-composite) value. The entity must have exactly one attribute annotatedNaturalId.- Specified by:
bySimpleNaturalIdin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- an instance of
SimpleNaturalIdLoadAccessfor executing the lookup
-
byMultipleNaturalId
Description copied from interface:SessionCreate aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the given entity type by their by natural id values, using batching.- Specified by:
byMultipleNaturalIdin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- an instance of
NaturalIdMultiLoadAccessfor executing the lookup
-
byMultipleNaturalId
Description copied from interface:SessionCreate aMultiIdentifierLoadAccessinstance to retrieve multiple instances of the named entity type by their by natural id values, using batching.- Specified by:
byMultipleNaturalIdin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- an instance of
NaturalIdMultiLoadAccessfor executing the lookup
-
enableFilter
Description copied from interface:SharedSessionContractEnable the named filter for this current session.The returned
Filterobject must be used to bind arguments to parameters of the filter, and every parameter must be set before any other operation of this session is called.- Specified by:
enableFilterin interfaceSession- Specified by:
enableFilterin interfaceSharedSessionContract- Parameters:
filterName- the name of the filter to be enabled.- Returns:
- the
Filterinstance representing the enabled filter. - See Also:
-
getEnabledFilter
Description copied from interface:SharedSessionContractRetrieve a currently enabled filter by name.- Specified by:
getEnabledFilterin interfaceSession- Specified by:
getEnabledFilterin interfaceSharedSessionContract- Parameters:
filterName- the name of the filter to be retrieved.- Returns:
- the
Filterinstance representing the enabled filter.
-
disableFilter
Description copied from interface:SharedSessionContractDisable the named filter for the current session.- Specified by:
disableFilterin interfaceSession- Specified by:
disableFilterin interfaceSharedSessionContract- Parameters:
filterName- the name of the filter to be disabled.
-
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
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:
-
setReadOnly
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:
-
doWork
Description copied from interface:SharedSessionContractPerform work using theConnectionunderlying by this session.- Specified by:
doWorkin interfaceSharedSessionContract- Parameters:
work- The work to be performed.- Throws:
HibernateException- Generally indicates wrappedSQLException
-
doReturningWork
Description copied from interface:SharedSessionContractPerform work using theConnectionunderlying by this session, and return a result.- Specified by:
doReturningWorkin interfaceSharedSessionContract- Type Parameters:
T- The type of the result returned from the work- Parameters:
work- The work to be performed.- Returns:
- the result of calling
ReturningWork.execute(java.sql.Connection). - Throws:
HibernateException- Generally indicates wrappedSQLException
-
isFetchProfileEnabled
Description copied from interface:SessionIs thefetch profilewith the given name enabled in this session?- Specified by:
isFetchProfileEnabledin interfaceSession- Parameters:
name- the name of the profile- Returns:
- True if fetch profile is enabled; false if not.
- Throws:
UnknownProfileException- Indicates that the given name does not match any known fetch profile names- See Also:
-
enableFetchProfile
Description copied from interface:SessionEnable thefetch profilewith the given name in this session. If the requested fetch 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 fetch profile names- See Also:
-
disableFetchProfile
Description copied from interface:SessionDisable thefetch profilewith the given name in this session. If the requested fetch profile is not currently 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 fetch profile names- See Also:
-
getLobHelper
Description copied from interface:Session- Specified by:
getLobHelperin interfaceSession- Returns:
- an instance of
LobHelper
-
addEventListeners
Description copied from interface:SessionAdd one or more listeners to the Session- Specified by:
addEventListenersin interfaceSession- Parameters:
listeners- the listener(s) to add
-
getActionQueue
Description copied from interface:SessionImplementorGet theActionQueueassociated with this session.- Specified by:
getActionQueuein interfaceSessionImplementor
-
instantiate
Description copied from interface:SharedSessionContractImplementorInstantiate the entity class of the givenEntityPersister, initializing the new instance with the given identifier.This is more efficient than
SharedSessionContractImplementor.instantiate(String, Object), but not always interchangeable, since a single persister might be responsible for multiple types.- Specified by:
instantiatein interfaceSessionImplementor- Specified by:
instantiatein interfaceSharedSessionContractImplementor- Throws:
HibernateException
-
forceFlush
Description copied from interface:SessionImplementorInitiate a flush to force deletion of a re-persisted entity.- Specified by:
forceFlushin interfaceSessionImplementor- Throws:
HibernateException
-
forceFlush
Description copied from interface:SessionImplementorInitiate a flush to force deletion of a re-persisted entity.- 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
- 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
- Specified by:
removeOrphanBeforeUpdatesin interfaceSessionImplementor
-
getSession
Description copied from interface:SharedSessionContractImplementorReturns this object, fulfilling the contract ofWrapperOptions.- Specified by:
getSessionin interfaceSessionImplementor- Specified by:
getSessionin interfaceSharedSessionContractImplementor- Specified by:
getSessionin interfaceWrapperOptions
-
useStreamForLobBinding
public boolean useStreamForLobBinding()Description copied from interface:WrapperOptionsDetermines whether streams should be used for binding LOB values.- Specified by:
useStreamForLobBindingin interfaceWrapperOptions- Returns:
true/false- See Also:
-
getPreferredSqlTypeCodeForBoolean
public int getPreferredSqlTypeCodeForBoolean()Description copied from interface:WrapperOptionsThe JDBCtype codeused to bind a null boolean value.- Specified by:
getPreferredSqlTypeCodeForBooleanin interfaceWrapperOptions- See Also:
-
getLobCreator
Description copied from interface:WrapperOptionsObtain access to theLobCreator.- Specified by:
getLobCreatorin interfaceWrapperOptions- Returns:
- The LOB creator
- See Also:
-
getJdbcBatchSize
Description copied from interface:SharedSessionContractGet the session-level JDBC batch size for the current session.- Specified by:
getJdbcBatchSizein interfaceJdbcSessionOwner- Specified by:
getJdbcBatchSizein interfaceSharedSessionContract- Returns:
- the current session-level JDBC batch size
- See Also:
-
getEventManager
- Specified by:
getEventManagerin interfaceJdbcSessionOwner
-
setJdbcBatchSize
Description copied from interface:SharedSessionContractSet the session-level JDBC batch size. Override the factory-level JDBC batch size controlled by the configuration property "hibernate.jdbc.batch_size".- Specified by:
setJdbcBatchSizein interfaceSharedSessionContract- Parameters:
jdbcBatchSize- the new session-level JDBC batch size- See Also:
-
isSubselectFetchingEnabled
public boolean isSubselectFetchingEnabled()Description copied from interface:SessionDetermine if subselect fetching is enabled in this session.- Specified by:
isSubselectFetchingEnabledin interfaceSession- Returns:
trueis subselect fetching is enabled
-
setSubselectFetchingEnabled
public void setSubselectFetchingEnabled(boolean enabled) Description copied from interface:SessionEnable or disable subselect fetching in this session. Override the factory-level default controlled by the configuration property "hibernate.use_subselect_fetch".- Specified by:
setSubselectFetchingEnabledin interfaceSession- Parameters:
enabled-trueto enable subselect fetching- See Also:
-
getFetchBatchSize
public int getFetchBatchSize()Description copied from interface:SessionGet the maximum batch size for batch fetching associations by id in this session.- Specified by:
getFetchBatchSizein interfaceSession
-
setFetchBatchSize
public void setFetchBatchSize(int batchSize) Description copied from interface:SessionSet the maximum batch size for batch fetching associations by id in this session. Override the factory-level default controlled by the configuration property "hibernate.default_batch_fetch_size".- If
batchSize>1, then batch fetching is enabled. - If
batchSize<0, the batch size is inherited from the factory-level setting. - Otherwise, batch fetching is disabled.
- Specified by:
setFetchBatchSizein interfaceSession- Parameters:
batchSize- the maximum batch size for batch fetching- See Also:
- If
-
getJdbcTimeZone
Description copied from interface:WrapperOptionsThe JDBCTimeZoneused when writing a value of typeTimeorTimestampto a JDBCPreparedStatement, or when reading from a JDBCResultSet.- When
getJdbcTimeZone()is null, the methodPreparedStatement.setTimestamp(int, java.sql.Timestamp)is called to write a timestamp, andResultSet.getTimestamp(int)is called to read a timestamp. - But when not null, the method
PreparedStatement.setTimestamp(int, java.sql.Timestamp, java.util.Calendar)is called to write a timestamp, andResultSet.getTimestamp(int, java.util.Calendar)is called to read a timestamp.
Thus, the storage
TimeZonecan differ from the default JVM TimeZone given byTimeZone.getDefault().- Specified by:
getJdbcTimeZonein interfaceWrapperOptions- Returns:
- the JDBC
TimeZone, or null if no JDBC timezone was explicitly set - See Also:
- When
-