Class SessionDelegatorBaseImpl
- All Implemented Interfaces:
EntityManager
,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).
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.hibernate.engine.jdbc.LobCreationContext
LobCreationContext.Callback<T>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionRetrieves the currentTransaction
, or creates a new transaction if there is no transaction active.void
addEventListeners
(SessionEventListener... listeners) Add one or more listeners to the Sessionvoid
afterOperation
(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.void
Called after each operation on aScrollableResults
, providing an opportunity for a stateless session to clear its temporary persistence context.void
An after-begin callback from the coordinator to its owner.void
afterTransactionCompletion
(boolean successful, boolean delayed) An after-completion callback to the owner.Cast this session toEventSource
if possible.boolean
autoFlushIfRequired
(Set<String> querySpaces) detect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flushboolean
autoFlushIfRequired
(Set<String> querySpaces, boolean skipPreFlush) void
void
A before-completion callback to the owner.Begin a unit of work and return the associatedTransaction
object.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.<T> IdentifierLoadAccess<T>
Create anIdentifierLoadAccess
instance to retrieve an instance of the given entity type by its primary key.<T> IdentifierLoadAccess<T>
Create anIdentifierLoadAccess
instance to retrieve an instance of the named entity type by its primary key.<T> MultiIdentifierLoadAccess<T>
byMultipleIds
(Class<T> entityClass) Create aMultiIdentifierLoadAccess
instance to retrieve multiple instances of the given entity type by their primary key values, using batching.<T> MultiIdentifierLoadAccess<T>
byMultipleIds
(String entityName) Create aMultiIdentifierLoadAccess
instance to retrieve multiple instances of the named entity type by their primary key values, using batching.<T> NaturalIdMultiLoadAccess<T>
byMultipleNaturalId
(Class<T> entityClass) Create aMultiIdentifierLoadAccess
instance to retrieve multiple instances of the given entity type by their by natural id values, using batching.<T> NaturalIdMultiLoadAccess<T>
byMultipleNaturalId
(String entityName) Create aMultiIdentifierLoadAccess
instance 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 aNaturalIdLoadAccess
instance 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 aNaturalIdLoadAccess
instance 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 aSimpleNaturalIdLoadAccess
instance 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 aSimpleNaturalIdLoadAccess
instance to retrieve an instance of the named entity type by its natural id, which must be a simple (non-composite) value.void
Cancel the execution of the current query.void
Check whether the session is open, and if not: mark the current transaction, if any, for rollback only, and throw anIllegalStateException
.void
checkOpen
(boolean markForRollbackIfClosed) Check whether the session is open, and if not: ifmarkForRollbackIfClosed = true
, mark the current transaction, if any, for rollback only, and throw anIllegalStateException
.void
checkTransactionNeededForUpdateOperation
(String exceptionMessage) Check if an activeTransaction
is available before performing an update operation against the database.void
clear()
Completely clear the session.void
close()
End the session by releasing the JDBC connection and cleaning up.boolean
boolean
Determine if the given entity is associated with this session.<T> RootGraphImplementor<T>
createEntityGraph
(Class<T> rootType) Create a new mutableEntityGraph
with only a root node.<T> RootGraph<T>
createEntityGraph
(Class<T> rootType, String graphName) Create a new mutable copy of the namedEntityGraph
, or returnnull
if there is no graph with the given name.createEntityGraph
(String graphName) Create a new mutable copy of the namedEntityGraph
, or returnnull
if there is no graph with the given name.createMutationQuery
(CriteriaDelete deleteQuery) Create aMutationQuery
from the given delete criteria treecreateMutationQuery
(CriteriaUpdate updateQuery) Create aMutationQuery
from the given update criteria treecreateMutationQuery
(String statementString) Create aMutationQuery
reference for the given HQL insert, update, or delete statement.createMutationQuery
(JpaCriteriaInsert insertSelect) Create aMutationQuery
from the given insert criteria treecreateMutationQuery
(JpaCriteriaInsertSelect insertSelect) Create aMutationQuery
from the given insert-select criteria treeCreate aMutationQuery
instance for the given named insert, update, or delete HQL query.createNamedQuery
(String name) Create a typedQuery
instance for the given named query.<T> QueryImplementor<T>
createNamedQuery
(String name, Class<T> resultClass) Create a typedQuery
instance for the given named query.Create aSelectionQuery
instance for the namedNamedQuery
.<R> SelectionQuery<R>
createNamedSelectionQuery
(String name, Class<R> resultType) Create aSelectionQuery
instance for the namedNamedQuery
with the given result type.Obtain aProcedureCall
based on a named templatecreateNativeMutationQuery
(String sqlString) Create aNativeQuery
instance for the given native SQL statement.createNativeQuery
(String sqlString) Create aNativeQuery
instance for the given native SQL query.createNativeQuery
(String sqlString, Class resultClass) Create aNativeQuery
instance for the given native SQL query using an implicit mapping to the specified Java type.<T> NativeQueryImplementor<T>
createNativeQuery
(String sqlString, Class<T> resultClass, String tableAlias) Create aNativeQuery
instance for the given native SQL query using an implicit mapping to the specified Java entity type.createNativeQuery
(String sqlString, String resultSetMappingName) Create aNativeQuery
instance for the given native SQL query using an explicit mapping to the specified Java type.<T> NativeQueryImplementor<T>
createNativeQuery
(String sqlString, String resultSetMappingName, Class<T> resultClass) Create aNativeQuery
instance for the given native SQL query using an explicit mapping to the specified Java type.createQuery
(CriteriaDelete deleteQuery) Create aQuery
for the given JPACriteriaDelete
.<T> QueryImplementor<T>
createQuery
(CriteriaQuery<T> criteriaQuery) Create aQuery
for the given JPACriteriaQuery
.<T> QueryImplementor<T>
createQuery
(CriteriaSelect<T> selectQuery) createQuery
(CriteriaUpdate updateQuery) Create aQuery
for the given JPACriteriaUpdate
.<T> QueryImplementor<T>
createQuery
(TypedQueryReference<T> typedQueryReference) Create a typedQuery
instance for the given typed query reference.createQuery
(String queryString) Create aQuery
instance for the given HQL query, or HQL insert, update, or delete statement.<T> QueryImplementor<T>
createQuery
(String queryString, Class<T> resultType) Create a typedQuery
instance for the given HQL query string and given query result type.<R> SelectionQuery<R>
createSelectionQuery
(CriteriaQuery<R> criteria) Create aSelectionQuery
reference for the givenCriteriaQuery
.createSelectionQuery
(String hqlString) Create aSelectionQuery
reference for the given HQLselect
statement.<R> SelectionQuery<R>
createSelectionQuery
(String hqlString, Class<R> resultType) Create aSelectionQuery
instance for the given HQL query string and given query result type.createStoredProcedureCall
(String procedureName) Create aProcedureCall
to a stored procedure.createStoredProcedureCall
(String procedureName, Class<?>... resultClasses) Create aProcedureCall
to a stored procedure with the given result set entity mappings.createStoredProcedureCall
(String procedureName, String... resultSetMappings) Create aProcedureCall
to a stored procedure with the given result set entity mappings.createStoredProcedureQuery
(String procedureName) Create aProcedureCall
to a stored procedure.createStoredProcedureQuery
(String procedureName, Class... resultClasses) Create aProcedureCall
to a stored procedure with the given result set entity mappings.createStoredProcedureQuery
(String procedureName, String... resultSetMappings) Create aProcedureCall
to a stored procedure with the given result set entity mappings.protected SessionImplementor
delegate()
Returns the delegate session.void
Remove this instance from the session cache.void
disableFetchProfile
(String name) Disable thefetch profile
with the given name in this session.void
disableFilter
(String filterName) Disable the named filter for the current session.<T> T
doReturningWork
(ReturningWork<T> work) Perform work using theConnection
underlying by this session, and return a result.void
Perform work using theConnection
underlying by this session.void
enableFetchProfile
(String name) Enable thefetch profile
with the given name in this session.enableFilter
(String filterName) Enable the named filter for this current session.void
Remove this instance from the session cache.<T> T
execute
(LobCreationContext.Callback<T> callback) Execute the given callback, making sure it has access to a viable JDBCConnection
.<T> T
find
(EntityGraph<T> entityGraph, Object primaryKey, FindOption... options) <T> @Nullable T
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.<T> T
find
(Class<T> entityClass, Object primaryKey, FindOption... options) <T> @Nullable T
find
(Class<T> entityClass, Object primaryKey, LockModeType lockMode) <T> @Nullable T
<T> @Nullable T
<T> T
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.<T> T
find
(Class<T> entityType, 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.<E> List<E>
findMultiple
(Class<E> entityType, List<Object> ids, FindOption... options) Return the persistent instances of the given entity class with the given identifiers as a list.void
flush()
Force this session to flush.void
void
Initiate a flush to force deletion of a re-persisted entity.void
Initiate a flush to force deletion of a re-persisted entity.generateEntityKey
(Object id, EntityPersister persister) Instantiate anEntityKey
with the given id and for the entity represented by the givenEntityPersister
.<T> T
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.<T> T
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.<T> T
get
(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 theActionQueue
associated with this session.Get the current cache mode for this session.The JPA-definedCacheRetrieveMode
.The JPA-definedCacheStoreMode
.The currentCacheTransactionSynchronization
associated 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 currentLockMode
of 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 namedEntityGraph
as an immutable graph, or returnnull
if there is no graph with the given name.<T> List<EntityGraph<? super T>>
getEntityGraphs
(Class<T> entityClass) Retrieve all namedEntityGraph
s with the given type.getEntityName
(Object object) Return the entity name for a persistent entity.getEntityPersister
(@Nullable String entityName, Object object) Get theEntityPersister
for the given entity instance.Get the entity instance associated with the givenEntityKey
, calling theInterceptor
if necessary.Get theSessionEventListenerManager
associated with this session.Obtain anExceptionConverter
for reporting an error.The factory which created this session.int
Get 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 theInterceptor
associated with this session.Get the session-level JDBC batch size for the current session.Obtain theJdbcCoordinator
for this session.Obtain theJdbcServices
for the factory which created this session.The JDBCTimeZone
used when writing a value of typeTime
orTimestamp
to a JDBCPreparedStatement
, or when reading from a JDBCResultSet
.Get theLoadQueryInfluencers
associated with this session.Obtain access to theLobCreator
.getLockMode
(Object entity) getNamedNativeQuery
(String name) Get aNativeQuery
instance for a named native SQL querygetNamedNativeQuery
(String name, String resultSetMapping) Get aNativeQuery
instance for a named native SQL querygetNamedProcedureCall
(String name) Obtain aProcedureCall
based on a named templategetNamedQuery
(String name) Create aQuery
instance for the named query.boolean
Get 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.int
The JDBCtype code
used to bind a null boolean value.<T> T
getReference
(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> T
getReference
(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 aUUID
which uniquely identifies this session.Get the statistics for this session.Obtain the tenant identifier associated with this session, as a string.Obtain the tenant identifier associated with this session.Get theTransaction
instance associated with this session.Obtain theTransactionCoordinator
.guessEntityName
(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.void
initializeCollection
(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.boolean
Is auto-close at transaction completion enabled?boolean
isClosed()
Determines whether the session is closed.boolean
Check if the session is currently connected.boolean
boolean
Will entities and proxies that are loaded into this session be made read-only by default?boolean
isDirty()
Does this session contain any changes which must be synchronized with the database? In other words, would any DML operations be executed if we flushed this session?boolean
Determines if this session implementsEventSource
.boolean
isFetchProfileEnabled
(String name) Is thefetch profile
with the given name enabled in this session?boolean
Check if the session is joined to the current transaction.boolean
isOpen()
Check if the session is still open.boolean
Determines whether the session is open or is waiting for auto-close.boolean
isReadOnly
(Object entityOrProxy) Is the specified entity or proxy read-only?boolean
Determine if subselect fetching is enabled in this session.boolean
Does this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?void
Join the currently-active JTA transaction.void
Read the persistent state associated with the given identifier into the given transient instance.void
lock
(Object entity, LockModeType lockMode) void
lock
(Object entity, LockModeType lockMode, LockOption... options) void
void
Obtain the specified lock level on the given managed instance associated with this session.void
lock
(Object object, LockOptions lockOptions) Obtain a lock on the given managed instance associated with this session, using the given lock options.void
lock
(String entityName, Object object, LockOptions lockOptions) Cascade the lock operation to the given child entity.void
Marks current transaction, if any, for rollback only.<T> T
Copy the state of the given object onto the persistent object with the same identifier.<T> T
merge
(T object) Copy the state of the given object onto the persistent object with the same identifier.void
Make a transient instance persistent and mark it for later insertion in the database.void
Make a transient instance persistent and mark it for later insertion in the database.void
prepareForQueryExecution
(boolean requiresTxn) Prepare for the execution of aQuery
orProcedureCall
void
Reread the state of the given managed instance associated with this session from the underlying database.void
refresh
(Object entity, LockModeType lockMode) void
void
refresh
(Object entity, RefreshOption... options) void
void
Reread the state of the given managed instance from the underlying database, obtaining the givenLockMode
.void
refresh
(Object object, LockOptions lockOptions) Reread the state of the given managed instance from the underlying database, obtaining the givenLockMode
.void
Mark a persistence instance associated with this session for removal from the underlying database.void
replicate
(Object object, ReplicationMode replicationMode) Persist the state of the given detached instance, reusing the current identifier value.void
replicate
(String entityName, Object object, ReplicationMode replicationMode) Persist the state of the given detached instance, reusing the current identifier value.Obtain aSession
builder with the ability to copy certain information from this session.void
setAutoClear
(boolean enabled) Enable or disable automatic cache clearing from after transaction completion.void
Set the current cache mode for this session.void
setCacheRetrieveMode
(CacheRetrieveMode cacheRetrieveMode) Enable or disable reads from the second-level cache.void
setCacheStoreMode
(CacheStoreMode cacheStoreMode) Enable or disable writes to the second-level cache.void
setCriteriaCopyTreeEnabled
(boolean jpaCriteriaCopyComplianceEnabled) void
setDefaultReadOnly
(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.void
setFetchBatchSize
(int batchSize) Set the maximum batch size for batch fetching associations by id in this session.void
setFlushMode
(FlushModeType flushModeType) Set the current JPA flush mode for this session.void
setHibernateFlushMode
(FlushMode flushMode) Set the current flush mode for this session.void
setJdbcBatchSize
(Integer jdbcBatchSize) Set the session-level JDBC batch size.void
setNativeJdbcParametersIgnored
(boolean nativeJdbcParametersIgnored) void
setProperty
(String propertyName, Object value) void
setReadOnly
(Object entityOrProxy, boolean readOnly) Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode.void
setSubselectFetchingEnabled
(boolean enabled) Enable or disable subselect fetching in this session.boolean
Should this session be automatically closed after the current transaction completes?boolean
Indicates whether an active transaction should be automatically joined.void
Callback indicating recognition of entering into a transactional context whether that is explicitly via the HibernateTransaction
API or via registration of Hibernate's JTA Synchronization impl with a JTA Transaction<T> T
boolean
Determines whether streams should be used for binding LOB values.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.hibernate.resource.jdbc.spi.JdbcSessionOwner
getSqlExceptionHelper
Methods inherited from interface org.hibernate.engine.jdbc.LobCreationContext
fromContext
Methods inherited from interface org.hibernate.engine.spi.SessionImplementor
asSessionImplementor, callWithConnection, isSessionImplementor, runWithConnection
Methods inherited from interface org.hibernate.engine.spi.SharedSessionContractImplementor
asStatelessSession, bestGuessEntityName, getConfiguredJdbcBatchSize, getSessionToken, getTypeConfiguration, isStatelessSession
Methods inherited from interface org.hibernate.type.descriptor.WrapperOptions
getDialect
-
Field Details
-
delegate
-
-
Constructor Details
-
SessionDelegatorBaseImpl
-
-
Method Details
-
delegate
Returns the delegate session.- See Also:
- API Note:
- This returns a different object to the
getDelegate()
method inherited fromEntityManager
.
-
execute
Description copied from interface:LobCreationContext
Execute the given callback, making sure it has access to a viable JDBCConnection
.- Specified by:
execute
in interfaceLobCreationContext
- Type Parameters:
T
- The Java type of the type of LOB being created. One ofBlob
,Clob
,NClob
- Parameters:
callback
- The callback to execute .- Returns:
- The LOB created by the callback.
-
getTenantIdentifier
Description copied from interface:SharedSessionContract
Obtain the tenant identifier associated with this session, as a string.- Specified by:
getTenantIdentifier
in interfaceSharedSessionContract
- Returns:
- The tenant identifier associated with this session, or
null
- See Also:
-
getTenantIdentifierValue
Description copied from interface:SharedSessionContract
Obtain the tenant identifier associated with this session.- Specified by:
getTenantIdentifierValue
in interfaceSharedSessionContract
- Returns:
- The tenant identifier associated with this session, or
null
- See Also:
-
getSessionIdentifier
Description copied from interface:SharedSessionContractImplementor
Obtain aUUID
which uniquely identifies this session.The UUID is useful mainly for logging.
- Specified by:
getSessionIdentifier
in interfaceSharedSessionContractImplementor
-
getJdbcConnectionAccess
- Specified by:
getJdbcConnectionAccess
in interfaceJdbcSessionOwner
-
generateEntityKey
Description copied from interface:SharedSessionContractImplementor
Instantiate anEntityKey
with the given id and for the entity represented by the givenEntityPersister
.- Specified by:
generateEntityKey
in interfaceSharedSessionContractImplementor
- Parameters:
id
- The entity idpersister
- The entity persister- Returns:
- The entity key
-
getInterceptor
Description copied from interface:SharedSessionContractImplementor
Retrieves theInterceptor
associated with this session.- Specified by:
getInterceptor
in interfaceSharedSessionContractImplementor
-
setAutoClear
public void setAutoClear(boolean enabled) Description copied from interface:SharedSessionContractImplementor
Enable or disable automatic cache clearing from after transaction completion.- Specified by:
setAutoClear
in interfaceSharedSessionContractImplementor
-
isTransactionInProgress
public boolean isTransactionInProgress()Description copied from interface:SharedSessionContractImplementor
Does this session have an active Hibernate transaction, or is it associated with a JTA transaction currently in progress?- Specified by:
isTransactionInProgress
in interfaceSharedSessionContractImplementor
-
checkTransactionNeededForUpdateOperation
Description copied from interface:SharedSessionContractImplementor
Check if an activeTransaction
is available before performing an update operation against the database.If an active transaction is necessary, but no transaction is active, a
TransactionRequiredException
is raised.- Specified by:
checkTransactionNeededForUpdateOperation
in interfaceSharedSessionContractImplementor
- Parameters:
exceptionMessage
- the message to use for theTransactionRequiredException
-
initializeCollection
public void initializeCollection(PersistentCollection<?> collection, boolean writing) throws HibernateException Description copied from interface:SharedSessionContractImplementor
Initialize the given collection (if not already initialized).- Specified by:
initializeCollection
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
internalLoad
public Object internalLoad(String entityName, Object id, boolean eager, boolean nullable) throws HibernateException Description copied from interface:SharedSessionContractImplementor
Obtain 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, anull
value is returned.
When
eager = true
, the object is eagerly fetched from the database.- Specified by:
internalLoad
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
- When
-
immediateLoad
Description copied from interface:SharedSessionContractImplementor
Load an instance immediately. This method is only called when lazily initializing a proxy. Do not return the proxy.- Specified by:
immediateLoad
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
getFactory
Description copied from interface:SharedSessionContract
The factory which created this session.- Specified by:
getFactory
in interfaceQueryProducerImplementor
- Specified by:
getFactory
in interfaceSharedSessionContract
- Specified by:
getFactory
in interfaceSharedSessionContractImplementor
-
getEntityPersister
public EntityPersister getEntityPersister(@Nullable String entityName, Object object) throws HibernateException Description copied from interface:SharedSessionContractImplementor
Get theEntityPersister
for the given entity instance.- Specified by:
getEntityPersister
in interfaceSharedSessionContractImplementor
- Parameters:
entityName
- optional entity nameobject
- the entity instance- Throws:
HibernateException
-
getEntityUsingInterceptor
Description copied from interface:SharedSessionContractImplementor
Get the entity instance associated with the givenEntityKey
, calling theInterceptor
if necessary.- Specified by:
getEntityUsingInterceptor
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
getContextEntityIdentifier
Description copied from interface:SharedSessionContractImplementor
Return the identifier of the persistent object, or null if it is not associated with this session.- Specified by:
getContextEntityIdentifier
in interfaceSharedSessionContractImplementor
-
bestGuessEntityName
Description copied from interface:SharedSessionContractImplementor
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.- Specified by:
bestGuessEntityName
in interfaceSharedSessionContractImplementor
-
guessEntityName
Description copied from interface:SharedSessionContractImplementor
Obtain an estimate of the entity name of the given entity instance, which is not involved in an association, using only theEntityNameResolver
.- Specified by:
guessEntityName
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
instantiate
Description copied from interface:SharedSessionContractImplementor
Instantiate the entity class, initializing with the given identifier.- Specified by:
instantiate
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
getPersistenceContext
Description copied from interface:SharedSessionContractImplementor
Get the persistence context for this session.See
SharedSessionContractImplementor.getPersistenceContextInternal()
for a faster alternative.- Specified by:
getPersistenceContext
in interfaceSharedSessionContractImplementor
-
getCacheMode
Description copied from interface:Session
Get the current cache mode for this session.- Specified by:
getCacheMode
in interfaceQueryProducerImplementor
- Specified by:
getCacheMode
in interfaceSession
- Specified by:
getCacheMode
in interfaceSharedSessionContractImplementor
- Returns:
- the current cache mode
-
getCacheRetrieveMode
Description copied from interface:Session
The JPA-definedCacheRetrieveMode
.- Specified by:
getCacheRetrieveMode
in interfaceEntityManager
- Specified by:
getCacheRetrieveMode
in interfaceSession
- See Also:
-
getCacheStoreMode
Description copied from interface:Session
The JPA-definedCacheStoreMode
.- Specified by:
getCacheStoreMode
in interfaceEntityManager
- Specified by:
getCacheStoreMode
in interfaceSession
- See Also:
-
setCacheMode
Description copied from interface:Session
Set 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:
setCacheMode
in interfaceSession
- Specified by:
setCacheMode
in interfaceSharedSessionContractImplementor
- Parameters:
cm
- the new cache mode
-
setCacheStoreMode
Description copied from interface:Session
Enable or disable writes to the second-level cache.- Specified by:
setCacheStoreMode
in interfaceEntityManager
- Specified by:
setCacheStoreMode
in interfaceSession
- Parameters:
cacheStoreMode
- a JPA-definedCacheStoreMode
- See Also:
-
setCacheRetrieveMode
Description copied from interface:Session
Enable or disable reads from the second-level cache.- Specified by:
setCacheRetrieveMode
in interfaceEntityManager
- Specified by:
setCacheRetrieveMode
in interfaceSession
- Parameters:
cacheRetrieveMode
- a JPA-definedCacheRetrieveMode
- See Also:
-
setCriteriaCopyTreeEnabled
public void setCriteriaCopyTreeEnabled(boolean jpaCriteriaCopyComplianceEnabled) - Specified by:
setCriteriaCopyTreeEnabled
in interfaceSharedSessionContractImplementor
-
isCriteriaCopyTreeEnabled
public boolean isCriteriaCopyTreeEnabled()- Specified by:
isCriteriaCopyTreeEnabled
in interfaceSharedSessionContractImplementor
-
getNativeJdbcParametersIgnored
public boolean getNativeJdbcParametersIgnored()- Specified by:
getNativeJdbcParametersIgnored
in interfaceSharedSessionContractImplementor
-
setNativeJdbcParametersIgnored
public void setNativeJdbcParametersIgnored(boolean nativeJdbcParametersIgnored) - Specified by:
setNativeJdbcParametersIgnored
in interfaceSharedSessionContractImplementor
-
isOpen
public boolean isOpen()Description copied from interface:SharedSessionContract
Check if the session is still open.- Specified by:
isOpen
in interfaceEntityManager
- Specified by:
isOpen
in interfaceSharedSessionContract
- Returns:
true
if it is open
-
isConnected
public boolean isConnected()Description copied from interface:SharedSessionContract
Check if the session is currently connected.- Specified by:
isConnected
in interfaceSharedSessionContract
- Returns:
true
if it is connected
-
checkOpen
public void checkOpen(boolean markForRollbackIfClosed) Description copied from interface:SharedSessionContractImplementor
Check whether the session is open, and if not:- if
markForRollbackIfClosed = true
, mark the current transaction, if any, for rollback only, and - throw an
IllegalStateException
. (JPA specifies this exception type.)
- Specified by:
checkOpen
in interfaceSharedSessionContractImplementor
- if
-
markForRollbackOnly
public void markForRollbackOnly()Description copied from interface:SharedSessionContractImplementor
Marks current transaction, if any, for rollback only.- Specified by:
markForRollbackOnly
in interfaceSharedSessionContractImplementor
-
getFlushMode
Description copied from interface:Session
Get the current JPA flush mode for this session.- Specified by:
getFlushMode
in interfaceEntityManager
- Specified by:
getFlushMode
in interfaceSession
- Specified by:
getFlushMode
in interfaceSharedSessionContractImplementor
- Returns:
- the
FlushModeType
currently in effect - See Also:
-
setFlushMode
Description copied from interface:Session
Set the current JPA 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.
- Specified by:
setFlushMode
in interfaceEntityManager
- Specified by:
setFlushMode
in interfaceSession
- Parameters:
flushModeType
- the newFlushModeType
- See Also:
-
setHibernateFlushMode
Description copied from interface:Session
Set 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.MANUAL
at the start of the session in order to avoid some unnecessary work.Note that
FlushMode
defines more options thanFlushModeType
.- Specified by:
setHibernateFlushMode
in interfaceSession
- Specified by:
setHibernateFlushMode
in interfaceSharedSessionContractImplementor
- Parameters:
flushMode
- the newFlushMode
-
getHibernateFlushMode
Description copied from interface:Session
Get the current flush mode for this session.- Specified by:
getHibernateFlushMode
in interfaceQueryProducerImplementor
- Specified by:
getHibernateFlushMode
in interfaceSession
- Specified by:
getHibernateFlushMode
in interfaceSharedSessionContractImplementor
- Returns:
- the
FlushMode
currently in effect
-
lock
- Specified by:
lock
in interfaceEntityManager
-
lock
- Specified by:
lock
in interfaceEntityManager
-
lock
- Specified by:
lock
in interfaceEntityManager
-
flush
public void flush()Description copied from interface:Session
Force 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:
flush
in interfaceEntityManager
- Specified by:
flush
in interfaceSession
- Specified by:
flush
in interfaceSharedSessionContractImplementor
-
isEventSource
public boolean isEventSource()Description copied from interface:SharedSessionContractImplementor
Determines if this session implementsEventSource
.Only stateful session are sources of events. If this object is a stateless session, this method return
false
.- Specified by:
isEventSource
in interfaceSharedSessionContractImplementor
-
asEventSource
Description copied from interface:SharedSessionContractImplementor
Cast this session toEventSource
if possible.Only stateful session are sources of events. If this object is a stateless session, this method throws.
- Specified by:
asEventSource
in interfaceSharedSessionContractImplementor
-
afterScrollOperation
public void afterScrollOperation()Description copied from interface:SharedSessionContractImplementor
Called 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:
afterScrollOperation
in interfaceSharedSessionContractImplementor
-
getTransactionCoordinator
Description copied from interface:JdbcSessionOwner
Obtain theTransactionCoordinator
.- Specified by:
getTransactionCoordinator
in interfaceJdbcSessionOwner
- Returns:
- The
TransactionCoordinator
-
getJdbcCoordinator
Description copied from interface:SharedSessionContractImplementor
Obtain theJdbcCoordinator
for this session.- Specified by:
getJdbcCoordinator
in interfaceSharedSessionContractImplementor
-
getJdbcServices
Description copied from interface:SharedSessionContractImplementor
Obtain theJdbcServices
for the factory which created this session.- Specified by:
getJdbcServices
in interfaceSharedSessionContractImplementor
-
getJdbcSessionContext
- Specified by:
getJdbcSessionContext
in interfaceJdbcSessionOwner
-
isClosed
public boolean isClosed()Description copied from interface:SharedSessionContractImplementor
Determines whether the session is closed.- Specified by:
isClosed
in interfaceSharedSessionContractImplementor
- Returns:
true
if the session is closed;false
otherwise.
-
checkOpen
public void checkOpen()Description copied from interface:SharedSessionContractImplementor
Check 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:
checkOpen
in interfaceSharedSessionContractImplementor
-
isOpenOrWaitingForAutoClose
public boolean isOpenOrWaitingForAutoClose()Description copied from interface:SharedSessionContractImplementor
Determines whether the session is open or is waiting for auto-close.- Specified by:
isOpenOrWaitingForAutoClose
in interfaceSharedSessionContractImplementor
- Returns:
true
if the session is closed, or if it's waiting for auto-close;false
otherwise.
-
shouldAutoClose
public boolean shouldAutoClose()Description copied from interface:SharedSessionContractImplementor
Should this session be automatically closed after the current transaction completes?- Specified by:
shouldAutoClose
in interfaceSharedSessionContractImplementor
-
isAutoCloseSessionEnabled
public boolean isAutoCloseSessionEnabled()Description copied from interface:SharedSessionContractImplementor
Is auto-close at transaction completion enabled?- Specified by:
isAutoCloseSessionEnabled
in interfaceSharedSessionContractImplementor
- See Also:
-
shouldAutoJoinTransaction
public boolean shouldAutoJoinTransaction()Description copied from interface:TransactionCoordinatorBuilder.Options
Indicates whether an active transaction should be automatically joined. Only relevant for JTA-based TransactionCoordinator instances.- Specified by:
shouldAutoJoinTransaction
in interfaceTransactionCoordinatorBuilder.Options
- Returns:
true
indicates the active transaction should be auto joined;false
indicates it should not (untilTransactionCoordinator.explicitJoin()
is called).
-
getLoadQueryInfluencers
Description copied from interface:SharedSessionContractImplementor
Get theLoadQueryInfluencers
associated with this session.- Specified by:
getLoadQueryInfluencers
in interfaceSharedSessionContractImplementor
- Returns:
- the
LoadQueryInfluencers
associated with this session; should never be null.
-
getExceptionConverter
Description copied from interface:SharedSessionContractImplementor
Obtain anExceptionConverter
for reporting an error.The converter associated to a session might be lazily initialized, so only invoke this getter when there's an actual need to use it.
- Specified by:
getExceptionConverter
in interfaceSharedSessionContractImplementor
- Returns:
- the ExceptionConverter for this Session.
-
getPersistenceContextInternal
Description copied from interface:SharedSessionContractImplementor
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.
- Specified by:
getPersistenceContextInternal
in interfaceSharedSessionContractImplementor
- Returns:
- the
PersistenceContext
associated to this session.
-
autoFlushIfRequired
Description copied from interface:SharedSessionContractImplementor
detect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flush- Specified by:
autoFlushIfRequired
in 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:
autoFlushIfRequired
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
autoPreFlush
public void autoPreFlush()- Specified by:
autoPreFlush
in interfaceSharedSessionContractImplementor
-
afterOperation
public void afterOperation(boolean success) Description copied from interface:SharedSessionContractImplementor
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.- Specified by:
afterOperation
in interfaceSharedSessionContractImplementor
- Parameters:
success
-true
if the operation a success
-
getEventListenerManager
Description copied from interface:SharedSessionContractImplementor
Get theSessionEventListenerManager
associated with this session.- Specified by:
getEventListenerManager
in interfaceSharedSessionContractImplementor
-
accessTransaction
Description copied from interface:SharedSessionContractImplementor
Retrieves the currentTransaction
, or creates a new transaction if there is no transaction active.This method is primarily for internal or integrator use.
- Specified by:
accessTransaction
in interfaceSharedSessionContractImplementor
- Returns:
- the
Transaction
-
beginTransaction
Description copied from interface:SharedSessionContract
Begin a unit of work and return the associatedTransaction
object. If a new underlying transaction is required, begin the transaction. Otherwise, continue the new work in the context of the existing underlying transaction.- Specified by:
beginTransaction
in interfaceSharedSessionContract
- Returns:
- an instance of
Transaction
representing the new transaction - See Also:
-
getTransaction
Description copied from interface:SharedSessionContract
Get theTransaction
instance associated with this session.- Specified by:
getTransaction
in interfaceEntityManager
- Specified by:
getTransaction
in interfaceSharedSessionContract
- Returns:
- an instance of
Transaction
representing the transaction associated with this session - See Also:
-
startTransactionBoundary
public void startTransactionBoundary()Description copied from interface:JdbcSessionOwner
Callback indicating recognition of entering into a transactional context whether that is explicitly via the HibernateTransaction
API or via registration of Hibernate's JTA Synchronization impl with a JTA Transaction- Specified by:
startTransactionBoundary
in interfaceJdbcSessionOwner
-
getCacheTransactionSynchronization
Description copied from interface:SharedSessionContractImplementor
The currentCacheTransactionSynchronization
associated with this session. This may benull
if the session is not currently associated with an active transaction.- Specified by:
getCacheTransactionSynchronization
in interfaceSharedSessionContractImplementor
-
afterTransactionBegin
public void afterTransactionBegin()Description copied from interface:JdbcSessionOwner
An after-begin callback from the coordinator to its owner.- Specified by:
afterTransactionBegin
in interfaceJdbcSessionOwner
-
beforeTransactionCompletion
public void beforeTransactionCompletion()Description copied from interface:JdbcSessionOwner
A before-completion callback to the owner.- Specified by:
beforeTransactionCompletion
in interfaceJdbcSessionOwner
-
afterTransactionCompletion
public void afterTransactionCompletion(boolean successful, boolean delayed) Description copied from interface:JdbcSessionOwner
An after-completion callback to the owner.- Specified by:
afterTransactionCompletion
in interfaceJdbcSessionOwner
- Parameters:
successful
- Was the transaction successful?delayed
- Is this a delayed after transaction completion call (aka after a timeout)?
-
flushBeforeTransactionCompletion
public void flushBeforeTransactionCompletion()- Specified by:
flushBeforeTransactionCompletion
in interfaceJdbcSessionOwner
-
getEntityManagerFactory
- Specified by:
getEntityManagerFactory
in interfaceEntityManager
-
getCriteriaBuilder
Description copied from interface:SharedSessionContract
- Specified by:
getCriteriaBuilder
in interfaceEntityManager
- Specified by:
getCriteriaBuilder
in interfaceSharedSessionContract
- Returns:
- an instance of
HibernateCriteriaBuilder
- See Also:
-
getMetamodel
- Specified by:
getMetamodel
in interfaceEntityManager
-
createEntityGraph
Description copied from interface:SharedSessionContract
Create a new mutableEntityGraph
with only a root node.- Specified by:
createEntityGraph
in interfaceEntityManager
- Specified by:
createEntityGraph
in interfaceSession
- Specified by:
createEntityGraph
in interfaceSessionImplementor
- Specified by:
createEntityGraph
in interfaceSharedSessionContract
- Parameters:
rootType
- the root entity class of the graph
-
createEntityGraph
Description copied from interface:SharedSessionContract
Create a new mutable copy of the namedEntityGraph
, or returnnull
if there is no graph with the given name.- Specified by:
createEntityGraph
in interfaceEntityManager
- Specified by:
createEntityGraph
in interfaceSession
- Specified by:
createEntityGraph
in interfaceSessionImplementor
- Specified by:
createEntityGraph
in interfaceSharedSessionContract
- Parameters:
graphName
- the name of the graph- See Also:
-
createEntityGraph
Description copied from interface:SharedSessionContract
Create a new mutable copy of the namedEntityGraph
, or returnnull
if there is no graph with the given name.- Specified by:
createEntityGraph
in interfaceSharedSessionContract
- Parameters:
rootType
- the root entity class of the graphgraphName
- the name of the graph- See Also:
-
getEntityGraph
Description copied from interface:SharedSessionContract
Retrieve the namedEntityGraph
as an immutable graph, or returnnull
if there is no graph with the given name.- Specified by:
getEntityGraph
in interfaceEntityManager
- Specified by:
getEntityGraph
in interfaceSession
- Specified by:
getEntityGraph
in interfaceSessionImplementor
- Specified by:
getEntityGraph
in interfaceSharedSessionContract
- Parameters:
graphName
- the name of the graph- See Also:
-
createQuery
- Specified by:
createQuery
in interfaceEntityManager
- Specified by:
createQuery
in interfaceSessionImplementor
-
getEntityGraphs
Description copied from interface:SharedSessionContract
Retrieve all namedEntityGraph
s with the given type.- Specified by:
getEntityGraphs
in interfaceEntityManager
- Specified by:
getEntityGraphs
in interfaceSession
- Specified by:
getEntityGraphs
in interfaceSharedSessionContract
- See Also:
-
createMutationQuery
Description copied from interface:QueryProducer
Create aMutationQuery
from the given update criteria tree- Specified by:
createMutationQuery
in interfaceQueryProducer
- Specified by:
createMutationQuery
in interfaceQueryProducerImplementor
-
createMutationQuery
Description copied from interface:QueryProducer
Create aMutationQuery
from the given delete criteria tree- Specified by:
createMutationQuery
in interfaceQueryProducer
- Specified by:
createMutationQuery
in interfaceQueryProducerImplementor
-
createMutationQuery
Description copied from interface:QueryProducer
Create aMutationQuery
from the given insert-select criteria tree- Specified by:
createMutationQuery
in interfaceQueryProducer
-
createMutationQuery
Description copied from interface:QueryProducer
Create aMutationQuery
from the given insert criteria tree- Specified by:
createMutationQuery
in interfaceQueryProducer
-
createQuery
Description copied from interface:QueryProducer
Create aQuery
for the given JPACriteriaQuery
.- Specified by:
createQuery
in interfaceEntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
- Specified by:
createQuery
in interfaceSession
-
createQuery
Description copied from interface:Session
Create aQuery
for the given JPACriteriaUpdate
.- Specified by:
createQuery
in interfaceEntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
- Specified by:
createQuery
in interfaceSession
-
createQuery
Description copied from interface:Session
Create aQuery
for the given JPACriteriaDelete
.- Specified by:
createQuery
in interfaceEntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
- Specified by:
createQuery
in interfaceSession
-
createQuery
Description copied from interface:QueryProducer
Create a typedQuery
instance for the given typed query reference.- Specified by:
createQuery
in interfaceEntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
- Specified by:
createQuery
in interfaceSession
- Parameters:
typedQueryReference
- the type query reference- Returns:
- The
Query
instance for execution - See Also:
-
getNamedQuery
Description copied from interface:QueryProducer
Create aQuery
instance for the named query.- Specified by:
getNamedQuery
in interfaceQueryProducer
- Specified by:
getNamedQuery
in interfaceQueryProducerImplementor
- Parameters:
name
- the name of a predefined named query- Returns:
- The
Query
instance for manipulation and execution
-
getNamedNativeQuery
Description copied from interface:QueryProducer
Get aNativeQuery
instance for a named native SQL query- Specified by:
getNamedNativeQuery
in interfaceQueryProducer
- Specified by:
getNamedNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
name
- The name of the predefined query- Returns:
- The
NativeQuery
instance for manipulation and execution
-
getNamedNativeQuery
Description copied from interface:QueryProducer
Get aNativeQuery
instance for a named native SQL query- Specified by:
getNamedNativeQuery
in interfaceQueryProducer
- Specified by:
getNamedNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
name
- The name of the predefined query- Returns:
- The
NativeQuery
instance for manipulation and execution
-
createQuery
Description copied from interface:QueryProducer
Create aQuery
instance for the given HQL query, or HQL insert, update, or delete statement.If a query has no explicit
select
list, the select list is inferred:- if there is exactly one root entity in the
from
clause, and it has no non-fetch
joins, then that root entity is the only element of the select list, or - if there is an entity with the alias
this
, then that entity is the only element of the select list, or - otherwise, the query is considered ambiguous, and this
method throws a
SemanticException
.
The query must have an explicit
from
clause, which can never be inferred.- Specified by:
createQuery
in interfaceEntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
- Specified by:
createQuery
in interfaceSession
- Parameters:
queryString
- The HQL query- Returns:
- The
Query
instance for manipulation and execution - See Also:
- if there is exactly one root entity in the
-
createSelectionQuery
Description copied from interface:QueryProducer
Create aSelectionQuery
reference for the given HQLselect
statement.If the statement has no explicit
select
list, the select list is inferred:- if there is exactly one root entity in the
from
clause, and it has no non-fetch
joins, then that root entity is the only element of the select list, or - if there is an entity with the alias
this
, then that entity is the only element of the select list, or - otherwise, the query is considered ambiguous, and this
method throws a
SemanticException
.
The query must have an explicit
from
clause, which can never be inferred.- Specified by:
createSelectionQuery
in interfaceQueryProducer
- if there is exactly one root entity in the
-
createSelectionQuery
Description copied from interface:QueryProducer
Create aSelectionQuery
instance for the given HQL query string and given query result type.- If the query has a single item in the
select
list, then the select item must be assignable to the given result type. - Otherwise, if there are multiple select items, then the
select items will be packaged into an instance of the
result type. The result type must have an appropriate
constructor with parameter types matching the select items,
or it must be one of the types
Object[]
,List
,Map
, orTuple
.
If a query has no explicit
select
list, the select list is inferred from the given query result type:- if the result type is an entity type, the query must have
exactly one root entity in the
from
clause, it must be assignable to the result type, and the inferred select list will contain just that entity, or - otherwise, the select list contains every root entity and
every non-
fetch
joined entity, and each query result will be packaged into an instance of the result type, just as specified above.
If a query has no explicit
from
clause, and the given result type is an entity type, the root entity is inferred to be the result type.Passing
Object.class
as the query result type is not recommended. In this special case, this method has the same semantics as the overloadQueryProducer.createSelectionQuery(String)
.The returned
Query
may be executed by callingQuery.getResultList()
orQuery.getSingleResult()
.- Specified by:
createSelectionQuery
in interfaceQueryProducer
- Parameters:
hqlString
- The HQLselect
query as a stringresultType
- TheClass
object representing the query result type, which should not beObject.class
- See Also:
- If the query has a single item in the
-
createSelectionQuery
Description copied from interface:QueryProducer
Create aSelectionQuery
reference for the givenCriteriaQuery
.- Specified by:
createSelectionQuery
in interfaceQueryProducer
- See Also:
-
createQuery
Description copied from interface:QueryProducer
Create a typedQuery
instance for the given HQL query string and given query result type.- If the query has a single item in the
select
list, then the select item must be assignable to the given result type. - Otherwise, if there are multiple select items, then the
select items will be packaged into an instance of the
result type. The result type must have an appropriate
constructor with parameter types matching the select items,
or it must be one of the types
Object[]
,List
,Map
, orTuple
.
If a query has no explicit
select
list, the select list is inferred from the given query result type:- if the result type is an entity type, the query must have
exactly one root entity in the
from
clause, it must be assignable to the result type, and the inferred select list will contain just that entity, or - otherwise, the select list contains every root entity and
every non-
fetch
joined entity, and each query result will be packaged into an instance of the result type, just as specified above.
If a query has no explicit
from
clause, and the given result type is an entity type, the root entity is inferred to be the result type.Passing
Object.class
as the query result type is not recommended. In this special case, this method has the same semantics as the overloadQueryProducer.createQuery(String)
.The returned
Query
may be executed by callingQuery.getResultList()
orQuery.getSingleResult()
.- Specified by:
createQuery
in interfaceEntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceQueryProducerImplementor
- Specified by:
createQuery
in interfaceSession
- Parameters:
queryString
- The HQL queryresultType
- TheClass
object representing the query result type, which should not beObject.class
- Returns:
- The
Query
instance for manipulation and execution - See Also:
- If the query has a single item in the
-
createNamedQuery
Description copied from interface:QueryProducer
Create a typedQuery
instance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQuery
in interfaceEntityManager
- Specified by:
createNamedQuery
in interfaceQueryProducer
- Specified by:
createNamedQuery
in interfaceQueryProducerImplementor
- Specified by:
createNamedQuery
in interfaceSession
- Parameters:
name
- the name of a predefined named query- Returns:
- The
Query
instance for manipulation and execution - See Also:
-
createNamedQuery
Description copied from interface:QueryProducer
Create a typedQuery
instance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQuery
in interfaceEntityManager
- Specified by:
createNamedQuery
in interfaceQueryProducer
- Specified by:
createNamedQuery
in interfaceQueryProducerImplementor
- Specified by:
createNamedQuery
in interfaceSession
- Parameters:
name
- the name of a query defined in metadataresultClass
- the type of the query result- Returns:
- The
Query
instance for manipulation and execution - See Also:
-
createNamedSelectionQuery
Description copied from interface:QueryProducer
Create aSelectionQuery
instance for the namedNamedQuery
.- Specified by:
createNamedSelectionQuery
in interfaceQueryProducer
-
createNamedSelectionQuery
Description copied from interface:QueryProducer
Create aSelectionQuery
instance for the namedNamedQuery
with the given result type.- Specified by:
createNamedSelectionQuery
in interfaceQueryProducer
-
createNativeQuery
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native SQL query.- Specified by:
createNativeQuery
in interfaceEntityManager
- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- a native SQL query string- Returns:
- The
NativeQuery
instance for manipulation and execution - See Also:
-
createNativeQuery
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native SQL query using an implicit mapping to the specified Java type.- If the given class is an entity class, this method is equivalent
to
createNativeQuery(sqlString).addEntity(resultClass)
. - If the given class has a registered
JavaType
, then the query must return a result set with a single column whoseJdbcType
is compatible with thatJavaType
. - Otherwise, the select items will be packaged into an instance of
the result type. The result type must have an appropriate
constructor with parameter types matching the select items, or it
must be one of the types
Object[]
,List
,Map
, orTuple
.
- Specified by:
createNativeQuery
in interfaceEntityManager
- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- The native (SQL) query stringresultClass
- The Java type to map results to- Returns:
- The
NativeQuery
instance for manipulation and execution - See Also:
- 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:QueryProducer
Create aNativeQuery
instance for the given native SQL query using an implicit mapping to the specified Java entity type.The given class must be an entity class. This method is equivalent to
createNativeQuery(sqlString).addEntity(tableAlias, resultClass)
.- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- Native (SQL) query stringresultClass
- The Java entity class to map results totableAlias
- The table alias for columns in the result set- Returns:
- The
NativeQuery
instance for manipulation and execution - See Also:
-
createNativeQuery
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native SQL query using an explicit mapping to the specified Java type.The given result set mapping name must identify a mapping defined by a
SqlResultSetMapping
annotation.- Specified by:
createNativeQuery
in interfaceEntityManager
- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- The native (SQL) query stringresultSetMappingName
- The explicit result mapping name- Returns:
- The
NativeQuery
instance for manipulation and execution - See Also:
-
createNativeQuery
public <T> NativeQueryImplementor<T> createNativeQuery(String sqlString, String resultSetMappingName, Class<T> resultClass) Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native SQL query using an explicit mapping to the specified Java type.The given result set mapping name must identify a mapping defined by a
SqlResultSetMapping
annotation.- Specified by:
createNativeQuery
in interfaceQueryProducer
- Specified by:
createNativeQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- The native (SQL) query stringresultSetMappingName
- The explicit result mapping name- Returns:
- The
NativeQuery
instance for manipulation and execution - See Also:
-
createMutationQuery
Description copied from interface:QueryProducer
Create aMutationQuery
reference for the given HQL insert, update, or delete statement.- Specified by:
createMutationQuery
in interfaceQueryProducer
- Specified by:
createMutationQuery
in interfaceQueryProducerImplementor
- Parameters:
statementString
- The HQLinsert
,update
, ordelete
statement
-
createNamedMutationQuery
Description copied from interface:QueryProducer
Create aMutationQuery
instance for the given named insert, update, or delete HQL query. The named query might be defined as HQL) or native-SQL.- Specified by:
createNamedMutationQuery
in interfaceQueryProducer
- Specified by:
createNamedMutationQuery
in interfaceQueryProducerImplementor
-
createNativeMutationQuery
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given native SQL statement.- Specified by:
createNativeMutationQuery
in interfaceQueryProducer
- Specified by:
createNativeMutationQuery
in interfaceQueryProducerImplementor
- Parameters:
sqlString
- a native SQL statement string- Returns:
- The NativeQuery instance for manipulation and execution
-
createNamedStoredProcedureQuery
Description copied from interface:SharedSessionContract
Obtain aProcedureCall
based on a named template- Specified by:
createNamedStoredProcedureQuery
in interfaceEntityManager
- Specified by:
createNamedStoredProcedureQuery
in interfaceSharedSessionContract
- Parameters:
name
- The name given to the template- Returns:
- The ProcedureCall
- See Also:
-
createStoredProcedureQuery
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure.- Specified by:
createStoredProcedureQuery
in interfaceEntityManager
- Specified by:
createStoredProcedureQuery
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureQuery
in interfaceEntityManager
- Specified by:
createStoredProcedureQuery
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.resultClasses
- The entity(s) to map the result on to.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureQuery
in interfaceEntityManager
- Specified by:
createStoredProcedureQuery
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.resultSetMappings
- The explicit result set mapping(s) to use for mapping the results- Returns:
- The representation of the procedure call.
-
prepareForQueryExecution
public void prepareForQueryExecution(boolean requiresTxn) Description copied from interface:SharedSessionContractImplementor
Prepare for the execution of aQuery
orProcedureCall
- Specified by:
prepareForQueryExecution
in interfaceSharedSessionContractImplementor
-
joinTransaction
public void joinTransaction()Description copied from interface:SharedSessionContract
Join the currently-active JTA transaction.- Specified by:
joinTransaction
in interfaceEntityManager
- Specified by:
joinTransaction
in interfaceSharedSessionContract
- See Also:
-
isJoinedToTransaction
public boolean isJoinedToTransaction()Description copied from interface:SharedSessionContract
Check if the session is joined to the current transaction.- Specified by:
isJoinedToTransaction
in interfaceEntityManager
- Specified by:
isJoinedToTransaction
in interfaceSharedSessionContract
- See Also:
-
unwrap
- Specified by:
unwrap
in interfaceEntityManager
-
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:
getDelegate
in interfaceEntityManager
- See Also:
-
getNamedProcedureCall
Description copied from interface:SharedSessionContract
Obtain aProcedureCall
based on a named template- Specified by:
getNamedProcedureCall
in interfaceSharedSessionContract
- Parameters:
name
- The name given to the template- Returns:
- The ProcedureCall
- See Also:
-
createStoredProcedureCall
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure.- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.resultClasses
- The entity(s) to map the result on to.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
Description copied from interface:SharedSessionContract
Create aProcedureCall
to a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.resultSetMappings
- The explicit result set mapping(s) to use for mapping the results- Returns:
- The representation of the procedure call.
-
sessionWithOptions
Description copied from interface:Session
Obtain aSession
builder with the ability to copy certain information from this session.- Specified by:
sessionWithOptions
in interfaceSession
- Returns:
- the session builder
-
getSessionFactory
Description copied from interface:Session
Get the session factory which created this session.- Specified by:
getSessionFactory
in interfaceSession
- Specified by:
getSessionFactory
in interfaceSessionImplementor
- Specified by:
getSessionFactory
in interfaceSharedSessionContractImplementor
- Specified by:
getSessionFactory
in interfaceWrapperOptions
- Returns:
- the session factory
- See Also:
-
close
Description copied from interface:SharedSessionContract
End the session by releasing the JDBC connection and cleaning up.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceEntityManager
- Specified by:
close
in interfaceSharedSessionContract
- Throws:
HibernateException
- Indicates problems cleaning up.
-
cancelQuery
Description copied from interface:Session
Cancel the execution of the current query.This is the sole method on session which may be safely called from another thread.
- Specified by:
cancelQuery
in interfaceSession
- Throws:
HibernateException
- if there was a problem cancelling the query
-
isDirty
Description copied from interface:Session
Does this session contain any changes which must be synchronized with the database? In other words, would any DML operations be executed if we flushed this session?- Specified by:
isDirty
in interfaceSession
- Returns:
true
if the session contains pending changes;false
otherwise.- Throws:
HibernateException
- could not perform dirtying checking
-
isDefaultReadOnly
public boolean isDefaultReadOnly()Description copied from interface:Session
Will 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:
isDefaultReadOnly
in interfaceSession
- Specified by:
isDefaultReadOnly
in 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:Session
Change 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
Query
useQuery.setReadOnly(boolean)
.- Specified by:
setDefaultReadOnly
in 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:Session
Return 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:
getIdentifier
in interfaceSession
- Parameters:
object
- a persistent instance associated with this session- Returns:
- the identifier
-
contains
Description copied from interface:Session
Determine if the given entity is associated with this session. -
contains
- Specified by:
contains
in interfaceEntityManager
-
getLockMode
- Specified by:
getLockMode
in interfaceEntityManager
-
setProperty
- Specified by:
setProperty
in interfaceEntityManager
-
getProperties
- Specified by:
getProperties
in interfaceEntityManager
-
evict
Description copied from interface:Session
Remove 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:Session
Read the persistent state associated with the given identifier into the given transient instance. -
replicate
Description copied from interface:Session
Persist 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:Session
Persist 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
. -
merge
public <T> T merge(T object) Description copied from interface:Session
Copy 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:
merge
in interfaceEntityManager
- Specified by:
merge
in interfaceSession
- Parameters:
object
- a detached instance with state to be copied- Returns:
- an updated persistent instance
-
merge
Description copied from interface:Session
Copy 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:Session
Make 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:
persist
in interfaceEntityManager
- Specified by:
persist
in interfaceSession
- Parameters:
object
- a transient instance to be made persistent
-
remove
Description copied from interface:Session
Mark 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
.Except when operating in fully JPA-compliant mode, this operation does, contrary to the JPA specification, accept a detached entity instance.
- Specified by:
remove
in interfaceEntityManager
- Specified by:
remove
in interfaceSession
- Parameters:
entity
- the managed persistent instance to remove, or a detached instance unless operating in fully JPA-compliant mode
-
find
Description copied from interface:Session
Return 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.The object returned by
get()
orfind()
is either an unproxied instance of the given entity class, or 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 of the requested instance is read directly from the database, either:
- call
EntityManager.find(Class, Object, FindOption...)
, passingCacheRetrieveMode.BYPASS
as an option, - call
Session.find(Class, Object, LockMode)
with the explicit lock modeLockMode.READ
, or - set the cache mode to
CacheRetrieveMode.BYPASS
before calling this method.
- Specified by:
find
in interfaceEntityManager
- Specified by:
find
in interfaceSession
- Parameters:
entityClass
- the entity typeprimaryKey
- an identifier- Returns:
- a fully-fetched persistent instance or null
- call
-
find
- Specified by:
find
in interfaceEntityManager
-
find
- Specified by:
find
in interfaceEntityManager
-
find
public <T> @Nullable T find(Class<T> entityClass, Object primaryKey, LockModeType lockMode, Map<String, Object> properties) - Specified by:
find
in interfaceEntityManager
-
find
- Specified by:
find
in interfaceEntityManager
-
find
- Specified by:
find
in interfaceEntityManager
-
find
Description copied from interface:Session
Return 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.find(Class, Object, LockOptions)
. -
find
Description copied from interface:Session
Return 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. -
getReference
Description copied from interface:Session
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. 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:
getReference
in interfaceEntityManager
- Specified by:
getReference
in 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:Session
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. 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:
getReference
in 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:Session
Make 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. -
lock
Description copied from interface:Session
Obtain 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_READ
orLockMode.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.WRITE
andLockMode.UPGRADE_SKIPLOCKED
are not legal arguments tolock()
. - perform a version check on an entity read from the second-level cache
by requesting
-
lock
Description copied from interface:SessionImplementor
Cascade the lock operation to the given child entity.- Specified by:
lock
in interfaceSessionImplementor
-
lock
Description copied from interface:Session
Obtain 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
. -
refresh
Description copied from interface:Session
Reread 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
Blob
orClob
.
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:
refresh
in interfaceEntityManager
- Specified by:
refresh
in interfaceSession
- Parameters:
object
- a persistent instance associated with this session
-
refresh
- Specified by:
refresh
in interfaceEntityManager
-
refresh
- Specified by:
refresh
in interfaceEntityManager
-
refresh
- Specified by:
refresh
in interfaceEntityManager
-
refresh
- Specified by:
refresh
in interfaceEntityManager
-
refresh
Description copied from interface:Session
Reread 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:Session
Reread the state of the given managed instance from the underlying database, obtaining the givenLockMode
. -
getCurrentLockMode
Description copied from interface:Session
Determine the currentLockMode
of the given managed instance associated with this session.- Specified by:
getCurrentLockMode
in interfaceSession
- Parameters:
object
- a persistent instance associated with this session- Returns:
- the current lock mode
-
clear
public void clear()Description copied from interface:Session
Completely 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:
clear
in interfaceEntityManager
- Specified by:
clear
in interfaceSession
-
detach
Description copied from interface:Session
Remove 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:
detach
in interfaceEntityManager
- Specified by:
detach
in interfaceSession
- Parameters:
entity
- the managed instance to detach
-
findMultiple
Description copied from interface:Session
Return the persistent instances of the given entity class with the given identifiers as a list. The position of an instance in the returned list matches the position of its identifier in the given list of identifiers, and the returned list contains a null value if there is no persistent instance matching a given identifier. If an instance is already associated with the session, that instance is returned. This method never returns an uninitialized instance.Every object returned by
findMultiple()
is either an unproxied instance of the given entity class, or a fully-fetched proxy object.This method accepts
BatchSize
as an option, allowing control over the number of records retrieved in a single database request. The performance impact of setting a batch size depends on whether a SQL array may be used to pass the list of identifiers to the database:- for databases which support standard SQL arrays, a smaller batch size might be extremely inefficient compared to a very large batch size or no batching at all, but
- on the other hand, for databases with no SQL array type, a large batch size results in long SQL statements with many JDBC parameters.
For more advanced cases, use
Session.byMultipleIds(Class)
, which returns an instance ofMultiIdentifierLoadAccess
.- Specified by:
findMultiple
in interfaceSession
- Parameters:
entityType
- the entity typeids
- the list of identifiersoptions
- options, if any- Returns:
- an ordered list of persistent instances, with null elements representing missing entities, whose positions in the list match the positions of their ids in the given list of identifiers
- See Also:
-
get
Description copied from interface:Session
Return 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.The object returned by
get()
orfind()
is either an unproxied instance of the given entity class, or 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.IGNORE
before calling this method.
- call
-
get
Description copied from interface:Session
Return 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)
. -
get
Description copied from interface:Session
Return 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:Session
Return 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:Session
Return 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:Session
Return 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:Session
Return the entity name for a persistent entity.- Specified by:
getEntityName
in 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:Session
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. 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:
getReference
in interfaceEntityManager
- Specified by:
getReference
in interfaceSession
- Parameters:
object
- a detached persistent instance- Returns:
- the persistent instance or proxy
-
byId
Description copied from interface:Session
Create anIdentifierLoadAccess
instance to retrieve an instance of the named entity type by its primary key.- Specified by:
byId
in interfaceSession
- Parameters:
entityName
- the entity name of the entity type to be retrieved- Returns:
- an instance of
IdentifierLoadAccess
for executing the lookup
-
byMultipleIds
Description copied from interface:Session
Create aMultiIdentifierLoadAccess
instance to retrieve multiple instances of the given entity type by their primary key values, using batching.- Specified by:
byMultipleIds
in interfaceSession
- Parameters:
entityClass
- the entity type to be retrieved- Returns:
- an instance of
MultiIdentifierLoadAccess
for executing the lookup - See Also:
-
byMultipleIds
Description copied from interface:Session
Create aMultiIdentifierLoadAccess
instance to retrieve multiple instances of the named entity type by their primary key values, using batching.- Specified by:
byMultipleIds
in interfaceSession
- Parameters:
entityName
- the entity name of the entity type to be retrieved- Returns:
- an instance of
MultiIdentifierLoadAccess
for executing the lookup
-
byId
Description copied from interface:Session
Create anIdentifierLoadAccess
instance to retrieve an instance of the given entity type by its primary key.- Specified by:
byId
in interfaceSession
- Parameters:
entityClass
- the entity type to be retrieved- Returns:
- an instance of
IdentifierLoadAccess
for executing the lookup
-
byNaturalId
Description copied from interface:Session
Create aNaturalIdLoadAccess
instance 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:
byNaturalId
in interfaceSession
- Parameters:
entityName
- the entity name of the entity type to be retrieved- Returns:
- an instance of
NaturalIdLoadAccess
for executing the lookup
-
byNaturalId
Description copied from interface:Session
Create aNaturalIdLoadAccess
instance 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:
byNaturalId
in interfaceSession
- Parameters:
entityClass
- the entity type to be retrieved- Returns:
- an instance of
NaturalIdLoadAccess
for executing the lookup
-
bySimpleNaturalId
Description copied from interface:Session
Create aSimpleNaturalIdLoadAccess
instance 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:
bySimpleNaturalId
in interfaceSession
- Parameters:
entityName
- the entity name of the entity type to be retrieved- Returns:
- an instance of
SimpleNaturalIdLoadAccess
for executing the lookup
-
bySimpleNaturalId
Description copied from interface:Session
Create aSimpleNaturalIdLoadAccess
instance 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:
bySimpleNaturalId
in interfaceSession
- Parameters:
entityClass
- the entity type to be retrieved- Returns:
- an instance of
SimpleNaturalIdLoadAccess
for executing the lookup
-
byMultipleNaturalId
Description copied from interface:Session
Create aMultiIdentifierLoadAccess
instance to retrieve multiple instances of the given entity type by their by natural id values, using batching.- Specified by:
byMultipleNaturalId
in interfaceSession
- Parameters:
entityClass
- the entity type to be retrieved- Returns:
- an instance of
NaturalIdMultiLoadAccess
for executing the lookup
-
byMultipleNaturalId
Description copied from interface:Session
Create aMultiIdentifierLoadAccess
instance to retrieve multiple instances of the named entity type by their by natural id values, using batching.- Specified by:
byMultipleNaturalId
in interfaceSession
- Parameters:
entityName
- the entity name of the entity type to be retrieved- Returns:
- an instance of
NaturalIdMultiLoadAccess
for executing the lookup
-
enableFilter
Description copied from interface:SharedSessionContract
Enable the named filter for this current session.The returned
Filter
object 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:
enableFilter
in interfaceSharedSessionContract
- Parameters:
filterName
- the name of the filter to be enabled.- Returns:
- the
Filter
instance representing the enabled filter. - See Also:
-
getEnabledFilter
Description copied from interface:SharedSessionContract
Retrieve a currently enabled filter by name.- Specified by:
getEnabledFilter
in interfaceSharedSessionContract
- Parameters:
filterName
- the name of the filter to be retrieved.- Returns:
- the
Filter
instance representing the enabled filter.
-
disableFilter
Description copied from interface:SharedSessionContract
Disable the named filter for the current session.- Specified by:
disableFilter
in interfaceSharedSessionContract
- Parameters:
filterName
- the name of the filter to be disabled.
-
getStatistics
Description copied from interface:Session
Get the statistics for this session.- Specified by:
getStatistics
in interfaceSession
- Returns:
- the session statistics being collected for this session
-
isReadOnly
Description copied from interface:Session
Is 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:
isReadOnly
in interfaceSession
- Parameters:
entityOrProxy
- an entity or proxy- Returns:
true
if the entity or proxy is read-only,false
if the entity or proxy is modifiable.- See Also:
-
setReadOnly
Description copied from interface:Session
Set 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
Query
useQuery.setReadOnly(boolean)
- Specified by:
setReadOnly
in interfaceSession
- Parameters:
entityOrProxy
- an entity or proxyreadOnly
-true
if the entity or proxy should be made read-only;false
if the entity or proxy should be made modifiable- See Also:
-
doWork
Description copied from interface:SharedSessionContract
Perform work using theConnection
underlying by this session.- Specified by:
doWork
in interfaceSharedSessionContract
- Parameters:
work
- The work to be performed.- Throws:
HibernateException
- Generally indicates wrappedSQLException
-
doReturningWork
Description copied from interface:SharedSessionContract
Perform work using theConnection
underlying by this session, and return a result.- Specified by:
doReturningWork
in interfaceSharedSessionContract
- Type Parameters:
T
- The type of the result returned from the work- Parameters:
work
- The work to be performed.- Returns:
- the result of calling
ReturningWork.execute(java.sql.Connection)
. - Throws:
HibernateException
- Generally indicates wrappedSQLException
-
isFetchProfileEnabled
Description copied from interface:Session
Is thefetch profile
with the given name enabled in this session?- Specified by:
isFetchProfileEnabled
in 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:Session
Enable thefetch profile
with the given name in this session. If the requested fetch profile is already enabled, the call has no effect.- Specified by:
enableFetchProfile
in 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:Session
Disable thefetch profile
with the given name in this session. If the requested fetch profile is not currently enabled, the call has no effect.- Specified by:
disableFetchProfile
in 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:
getLobHelper
in interfaceSession
- Returns:
- an instance of
LobHelper
-
addEventListeners
Description copied from interface:Session
Add one or more listeners to the Session- Specified by:
addEventListeners
in interfaceSession
- Parameters:
listeners
- the listener(s) to add
-
getActionQueue
Description copied from interface:SessionImplementor
Get theActionQueue
associated with this session.- Specified by:
getActionQueue
in interfaceSessionImplementor
-
instantiate
Description copied from interface:SharedSessionContractImplementor
Instantiate 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:
instantiate
in interfaceSessionImplementor
- Specified by:
instantiate
in interfaceSharedSessionContractImplementor
- Throws:
HibernateException
-
forceFlush
Description copied from interface:SessionImplementor
Initiate a flush to force deletion of a re-persisted entity.- Specified by:
forceFlush
in interfaceSessionImplementor
- Throws:
HibernateException
-
forceFlush
Description copied from interface:SessionImplementor
Initiate a flush to force deletion of a re-persisted entity.- Specified by:
forceFlush
in interfaceSessionImplementor
- Throws:
HibernateException
-
getSession
Description copied from interface:SharedSessionContractImplementor
Returns this object, fulfilling the contract ofWrapperOptions
.- Specified by:
getSession
in interfaceSessionImplementor
- Specified by:
getSession
in interfaceSharedSessionContractImplementor
- Specified by:
getSession
in interfaceWrapperOptions
-
useStreamForLobBinding
public boolean useStreamForLobBinding()Description copied from interface:WrapperOptions
Determines whether streams should be used for binding LOB values.- Specified by:
useStreamForLobBinding
in interfaceWrapperOptions
- Returns:
true
/false
- See Also:
-
getPreferredSqlTypeCodeForBoolean
public int getPreferredSqlTypeCodeForBoolean()Description copied from interface:WrapperOptions
The JDBCtype code
used to bind a null boolean value.- Specified by:
getPreferredSqlTypeCodeForBoolean
in interfaceWrapperOptions
- See Also:
-
getLobCreator
Description copied from interface:WrapperOptions
Obtain access to theLobCreator
.- Specified by:
getLobCreator
in interfaceWrapperOptions
- Returns:
- The LOB creator
- See Also:
-
getJdbcBatchSize
Description copied from interface:SharedSessionContract
Get the session-level JDBC batch size for the current session.- Specified by:
getJdbcBatchSize
in interfaceJdbcSessionOwner
- Specified by:
getJdbcBatchSize
in interfaceSharedSessionContract
- Returns:
- the current session-level JDBC batch size
- See Also:
-
getEventManager
- Specified by:
getEventManager
in interfaceJdbcSessionOwner
-
setJdbcBatchSize
Description copied from interface:SharedSessionContract
Set the session-level JDBC batch size. Override the factory-level JDBC batch size controlled by the configuration property "hibernate.jdbc.batch_size".- Specified by:
setJdbcBatchSize
in interfaceSharedSessionContract
- Parameters:
jdbcBatchSize
- the new session-level JDBC batch size- See Also:
-
isSubselectFetchingEnabled
public boolean isSubselectFetchingEnabled()Description copied from interface:Session
Determine if subselect fetching is enabled in this session.- Specified by:
isSubselectFetchingEnabled
in interfaceSession
- Returns:
true
is subselect fetching is enabled
-
setSubselectFetchingEnabled
public void setSubselectFetchingEnabled(boolean enabled) Description copied from interface:Session
Enable or disable subselect fetching in this session. Override the factory-level default controlled by the configuration property "hibernate.use_subselect_fetch".- Specified by:
setSubselectFetchingEnabled
in interfaceSession
- Parameters:
enabled
-true
to enable subselect fetching- See Also:
-
getFetchBatchSize
public int getFetchBatchSize()Description copied from interface:Session
Get the maximum batch size for batch fetching associations by id in this session.- Specified by:
getFetchBatchSize
in interfaceSession
-
setFetchBatchSize
public void setFetchBatchSize(int batchSize) Description copied from interface:Session
Set 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:
setFetchBatchSize
in interfaceSession
- Parameters:
batchSize
- the maximum batch size for batch fetching- See Also:
- If
-
getJdbcTimeZone
Description copied from interface:WrapperOptions
The JDBCTimeZone
used when writing a value of typeTime
orTimestamp
to a JDBCPreparedStatement
, or when reading from a JDBCResultSet
.- When
getJdbcTimeZone()
is null, the methodPreparedStatement.setTimestamp(int, java.sql.Timestamp)
is called to write a timestamp, andResultSet.getTimestamp(int)
is called to read a timestamp. - But when not null, the method
PreparedStatement.setTimestamp(int, java.sql.Timestamp, java.util.Calendar)
is called to write a timestamp, andResultSet.getTimestamp(int, java.util.Calendar)
is called to read a timestamp.
Thus, the storage
TimeZone
can differ from the default JVM TimeZone given byTimeZone.getDefault()
.- Specified by:
getJdbcTimeZone
in interfaceWrapperOptions
- Returns:
- the JDBC
TimeZone
, or null if no JDBC timezone was explicitly set - See Also:
- When
-