Class SessionLazyDelegator
- java.lang.Object
-
- org.hibernate.engine.spi.SessionLazyDelegator
-
- All Implemented Interfaces:
EntityManager,Closeable,Serializable,AutoCloseable,QueryProducer,Session,SharedSessionContract
public class SessionLazyDelegator extends Object implements Session
This helper class allows decorating a Session instance, while the instance itself is lazily provided via aSupplier. When the decorated instance is readily available, one should prefer usingSessionDelegatorBaseImpl. Another difference with SessionDelegatorBaseImpl is that this type only implements Session.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hibernate.Session
Session.LockRequest
-
-
Constructor Summary
Constructors Constructor Description SessionLazyDelegator(Supplier<Session> lazySessionLookup)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddEventListeners(SessionEventListener... listeners)Add one or more listeners to the SessionTransactionbeginTransaction()Begin a unit of work and return the associatedTransactionobject.Session.LockRequestbuildLockRequest(LockOptions lockOptions)Deprecated.<T> IdentifierLoadAccess<T>byId(Class<T> entityClass)Create anIdentifierLoadAccessinstance to retrieve the specified entity by primary key.<T> IdentifierLoadAccess<T>byId(String entityName)Create anIdentifierLoadAccessinstance to retrieve the specified entity type by primary key.<T> MultiIdentifierLoadAccess<T>byMultipleIds(Class<T> entityClass)Create aMultiIdentifierLoadAccessinstance to retrieve multiple entities at once as specified by primary key values.<T> MultiIdentifierLoadAccess<T>byMultipleIds(String entityName)Create aMultiIdentifierLoadAccessinstance to retrieve multiple entities at once as specified by primary key values.<T> NaturalIdMultiLoadAccess<T>byMultipleNaturalId(Class<T> entityClass)Access to load multiple entities bynatural id.<T> NaturalIdMultiLoadAccess<T>byMultipleNaturalId(String entityName)Access to load multiple entities bynatural id.<T> NaturalIdLoadAccess<T>byNaturalId(Class<T> entityClass)Create aNaturalIdLoadAccessinstance to retrieve the specified entity by its natural id.<T> NaturalIdLoadAccess<T>byNaturalId(String entityName)Create aNaturalIdLoadAccessinstance to retrieve the specified entity by its natural id.<T> SimpleNaturalIdLoadAccess<T>bySimpleNaturalId(Class<T> entityClass)Create aSimpleNaturalIdLoadAccessinstance to retrieve the specified entity by its simple (single attribute)natural id.<T> SimpleNaturalIdLoadAccess<T>bySimpleNaturalId(String entityName)Create aSimpleNaturalIdLoadAccessinstance to retrieve the specified entity by itsnatural id.voidcancelQuery()Cancel the execution of the current query.voidclear()Completely clear the session.voidclose()End the session by releasing the JDBC connection and cleaning up.booleancontains(Object entity)booleancontains(String entityName, Object object)Determine if the given entity is associated with this session.<T> RootGraph<T>createEntityGraph(Class<T> rootType)RootGraph<?>createEntityGraph(String graphName)MutationQuerycreateMutationQuery(CriteriaDelete deleteQuery)Create aMutationQueryfrom the given delete criteria treeMutationQuerycreateMutationQuery(CriteriaUpdate updateQuery)Create aMutationQueryfrom the given update criteria treeMutationQuerycreateMutationQuery(String hqlString)Create a MutationQuery reference for the given HQL insert, update, or delete statement.MutationQuerycreateMutationQuery(JpaCriteriaInsertSelect insertSelect)Create aMutationQueryfrom the given insert-select criteria treeMutationQuerycreateNamedMutationQuery(String name)Create aMutationQueryinstance for the given named insert, update, or delete HQL query.QuerycreateNamedQuery(String name)Deprecated.<R> Query<R>createNamedQuery(String name, Class<R> resultClass)Create a typedQueryinstance for the given named query.SelectionQuery<?>createNamedSelectionQuery(String name)Create aSelectionQueryinstance for the namedNamedQuery<R> SelectionQuery<R>createNamedSelectionQuery(String name, Class<R> resultType)Create aSelectionQueryinstance for the namedNamedQuerywith the expected result-typeProcedureCallcreateNamedStoredProcedureQuery(String name)Obtain aProcedureCallbased on a named templateMutationQuerycreateNativeMutationQuery(String sqlString)Create aNativeQueryinstance for the given native SQL statement.NativeQuerycreateNativeQuery(String sqlString)Deprecated.NativeQuerycreateNativeQuery(String sqlString, Class resultClass)Create aNativeQueryinstance for the given native SQL query using implicit mapping to the specified Java type.<R> NativeQuery<R>createNativeQuery(String sqlString, Class<R> resultClass, String tableAlias)Create aNativeQueryinstance for the given native SQL query using implicit mapping to the specified Java type.NativeQuerycreateNativeQuery(String sqlString, String resultSetMappingName)Deprecated.<R> NativeQuery<R>createNativeQuery(String sqlString, String resultSetMappingName, Class<R> resultClass)Create aNativeQueryinstance for the given native SQL query using an explicit mapping to the specified Java type.QuerycreateQuery(CriteriaDelete deleteQuery)Deprecated.<R> Query<R>createQuery(CriteriaQuery<R> criteriaQuery)Create aQueryfor the given JPACriteriaQuery.QuerycreateQuery(CriteriaUpdate updateQuery)Deprecated.QuerycreateQuery(String queryString)Deprecated.<R> Query<R>createQuery(String queryString, Class<R> resultClass)Create a typedQueryinstance for the given HQL query string.<R> SelectionQuery<R>createSelectionQuery(CriteriaQuery<R> criteria)Create aSelectionQueryreference for the given Criteria.SelectionQuery<?>createSelectionQuery(String hqlString)Create aSelectionQueryreference for the given HQL.<R> SelectionQuery<R>createSelectionQuery(String hqlString, Class<R> resultType)Create aSelectionQueryreference for the given HQL.ProcedureCallcreateStoredProcedureCall(String procedureName)Create aProcedureCallto a stored procedure.ProcedureCallcreateStoredProcedureCall(String procedureName, Class<?>... resultClasses)Create aProcedureCallto a stored procedure with the given result set entity mappings.ProcedureCallcreateStoredProcedureCall(String procedureName, String... resultSetMappings)Create aProcedureCallto a stored procedure with the given result set entity mappings.ProcedureCallcreateStoredProcedureQuery(String procedureName)Create aProcedureCallto a stored procedure.ProcedureCallcreateStoredProcedureQuery(String procedureName, Class... resultClasses)Create aProcedureCallto a stored procedure with the given result set entity mappings.ProcedureCallcreateStoredProcedureQuery(String procedureName, String... resultSetMappings)Create aProcedureCallto a stored procedure with the given result set entity mappings.voiddelete(Object object)Deprecated.voiddelete(String entityName, Object object)Deprecated.voiddetach(Object object)Remove this instance from the session cache.voiddisableFetchProfile(String name)Disable thefetch profilewith the given name in this session.voiddisableFilter(String filterName)Disable the named filter for the current session.<T> TdoReturningWork(ReturningWork<T> work)Perform work using theConnectionunderlying by this session, and return a result.voiddoWork(Work work)Perform work using theConnectionunderlying by this session.voidenableFetchProfile(String name)Enable thefetch profilewith the given name in this session.FilterenableFilter(String filterName)Enable the named filter for this current session.voidevict(Object object)Remove this instance from the session cache.<T> Tfind(Class<T> entityClass, Object primaryKey)<T> Tfind(Class<T> entityClass, Object primaryKey, LockModeType lockMode)<T> Tfind(Class<T> entityClass, Object primaryKey, LockModeType lockMode, Map<String,Object> properties)<T> Tfind(Class<T> entityClass, Object primaryKey, Map<String,Object> properties)voidflush()Force this session to flush.<T> Tget(Class<T> entityType, Object id)Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.<T> Tget(Class<T> entityType, Object id, LockMode lockMode)Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.<T> Tget(Class<T> 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.Objectget(String entityName, Object id)Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance.Objectget(String entityName, Object id, LockMode lockMode)Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.Objectget(String entityName, Object id, LockOptions lockOptions)Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance.CacheModegetCacheMode()Get the currentcache modefor this session.CacheRetrieveModegetCacheRetrieveMode()The JPA-definedCacheRetrieveMode.CacheStoreModegetCacheStoreMode()The JPA-definedCacheStoreMode.HibernateCriteriaBuildergetCriteriaBuilder()LockModegetCurrentLockMode(Object object)Determine the currentLockModeof the given managed instance associated with this session.ObjectgetDelegate()FiltergetEnabledFilter(String filterName)Retrieve a currently enabled filter by name.RootGraph<?>getEntityGraph(String graphName)<T> List<EntityGraph<? super T>>getEntityGraphs(Class<T> entityClass)EntityManagerFactorygetEntityManagerFactory()StringgetEntityName(Object object)Return the entity name for a persistent entity.FlushModeTypegetFlushMode()Get the currentJPA flush modefor this session.FlushModegetHibernateFlushMode()Get the currentflush modefor this session.ObjectgetIdentifier(Object object)Return the identifier value of the given entity associated with this session.IntegergetJdbcBatchSize()Get the session-level JDBC batch size for the current session.LobHelpergetLobHelper()LockModeTypegetLockMode(Object entity)MetamodelgetMetamodel()NativeQuerygetNamedNativeQuery(String name)Deprecated.NativeQuerygetNamedNativeQuery(String name, String resultSetMapping)Deprecated.ProcedureCallgetNamedProcedureCall(String name)Obtain aProcedureCallbased on a named templateQuerygetNamedQuery(String queryName)Deprecated.Map<String,Object>getProperties()<T> TgetReference(Class<T> entityType, Object id)Return a reference to the persistent instance with the given class and identifier, making the assumption that the instance is still persistent in the database.ObjectgetReference(String entityName, Object id)Return a reference to the persistent instance of the given named entity with the given identifier, making the assumption that the instance is still persistent in the database.<T> TgetReference(T object)Return a reference to the persistent instance with the same identity as the given instance, which might be detached, making the assumption that the instance is still persistent in the database.SessionFactorygetSessionFactory()Get the session factory which created this session.SessionStatisticsgetStatistics()Get the statistics for this session.StringgetTenantIdentifier()Obtain the tenant identifier associated with this session.TransactiongetTransaction()Get theTransactioninstance associated with this session.booleanisConnected()Check if the session is currently connected.booleanisDefaultReadOnly()Will entities and proxies that are loaded into this session be made read-only by default?booleanisDirty()Does this session contain any changes which must be synchronized with the database? In other words, would any DML operations be executed if we flushed this session?booleanisFetchProfileEnabled(String name)Is thefetch profilewith the given name enabled in this session?booleanisJoinedToTransaction()Check if the session is joined to the current transaction.booleanisOpen()Check if the session is still open.booleanisReadOnly(Object entityOrProxy)Is the specified entity or proxy read-only?voidjoinTransaction()Join the currently-active JTA transaction.<T> Tload(Class<T> theClass, Object id)Deprecated.<T> Tload(Class<T> theClass, Object id, LockMode lockMode)Deprecated.<T> Tload(Class<T> theClass, Object id, LockOptions lockOptions)Deprecated.voidload(Object object, Object id)Read the persistent state associated with the given identifier into the given transient instance.Objectload(String entityName, Object id)Deprecated.Objectload(String entityName, Object id, LockMode lockMode)Deprecated.Objectload(String entityName, Object id, LockOptions lockOptions)Deprecated.voidlock(Object entity, LockModeType lockMode)voidlock(Object entity, LockModeType lockMode, Map<String,Object> properties)voidlock(Object object, LockMode lockMode)Obtain the specified lock level on the given managed instance associated with this session.voidlock(Object object, LockOptions lockOptions)Obtain a lock on the given managed instance associated with this session, using the givenlock options.voidlock(String entityName, Object object, LockMode lockMode)Deprecated.<T> Tmerge(String entityName, T object)Copy the state of the given object onto the persistent object with the same identifier.<T> Tmerge(T object)Copy the state of the given object onto the persistent object with the same identifier.voidpersist(Object object)Make a transient instance persistent and mark it for later insertion in the database.voidpersist(String entityName, Object object)Make a transient instance persistent and mark it for later insertion in the database.voidrefresh(Object object)Reread the state of the given managed instance associated with this session from the underlying database.voidrefresh(Object entity, LockModeType lockMode)voidrefresh(Object entity, LockModeType lockMode, Map<String,Object> properties)voidrefresh(Object entity, Map<String,Object> properties)voidrefresh(Object object, LockMode lockMode)Reread the state of the given managed instance from the underlying database, obtaining the givenLockMode.voidrefresh(Object object, LockOptions lockOptions)Reread the state of the given managed instance from the underlying database, obtaining the givenLockMode.voidrefresh(String entityName, Object object)Deprecated.voidrefresh(String entityName, Object object, LockOptions lockOptions)Deprecated.voidremove(Object object)Mark a persistence instance associated with this session for removal from the underlying database.voidreplicate(Object object, ReplicationMode replicationMode)Deprecated.voidreplicate(String entityName, Object object, ReplicationMode replicationMode)Deprecated.Objectsave(Object object)Deprecated.Objectsave(String entityName, Object object)Deprecated.voidsaveOrUpdate(Object object)Deprecated.voidsaveOrUpdate(String entityName, Object object)Deprecated.SharedSessionBuildersessionWithOptions()Obtain aSessionbuilder with the ability to copy certain information from this session.voidsetCacheMode(CacheMode cacheMode)Set the currentcache modefor this session.voidsetCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode)Enable or disable reads from the second-level cache.voidsetCacheStoreMode(CacheStoreMode cacheStoreMode)Enable or disable writes to the second-level cache.voidsetDefaultReadOnly(boolean readOnly)Change the default for entities and proxies loaded into this session from modifiable to read-only mode, or from modifiable to read-only mode.voidsetFlushMode(FlushModeType flushMode)Set the currentJPA flush modefor this session.voidsetHibernateFlushMode(FlushMode flushMode)Set the currentflush modefor this session.voidsetJdbcBatchSize(Integer jdbcBatchSize)Set the session-level JDBC batch size.voidsetProperty(String propertyName, Object value)voidsetReadOnly(Object entityOrProxy, boolean readOnly)Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode.<T> Tunwrap(Class<T> cls)voidupdate(Object object)Deprecated.voidupdate(String entityName, Object object)Deprecated.
-
-
-
Method Detail
-
flush
public void flush()
Description copied from interface:SessionForce this session to flush. Must be called at the end of a unit of work, before the transaction is committed. Depending on the current flush mode, the session might automatically flush whenEntityTransaction.commit()is called, and it is not necessary to call this method directly.Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.
- Specified by:
flushin interfaceEntityManager- Specified by:
flushin interfaceSession
-
setFlushMode
public void setFlushMode(FlushModeType flushMode)
Description copied from interface:SessionSet the currentJPA flush modefor this session.Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory. The current flush mode determines when the session is automatically flushed.
- Specified by:
setFlushModein interfaceEntityManager- Specified by:
setFlushModein interfaceSession- Parameters:
flushMode- the newFlushModeType- See Also:
for additional options
-
setHibernateFlushMode
public void setHibernateFlushMode(FlushMode flushMode)
Description copied from interface:SessionSet the currentflush modefor this session.Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory. The current flush mode determines when the session is automatically flushed.
The
default flush modeis sometimes unnecessarily aggressive. For a logically "read only" session, it's reasonable to set the session's flush mode toFlushMode.MANUALat the start of the session in order to avoid some unnecessary work.Note that
FlushModedefines more options thanFlushModeType.- Specified by:
setHibernateFlushModein interfaceSession- Parameters:
flushMode- the newFlushMode
-
getFlushMode
public FlushModeType getFlushMode()
Description copied from interface:SessionGet the currentJPA flush modefor this session.- Specified by:
getFlushModein interfaceEntityManager- Specified by:
getFlushModein interfaceSession- Returns:
- the
FlushModeTypecurrently in effect
-
getHibernateFlushMode
public FlushMode getHibernateFlushMode()
Description copied from interface:SessionGet the currentflush modefor this session.- Specified by:
getHibernateFlushModein interfaceSession- Returns:
- the
FlushModecurrently in effect
-
setCacheMode
public void setCacheMode(CacheMode cacheMode)
Description copied from interface:SessionSet the currentcache modefor this session.The cache mode determines the manner in which this session can interact with the second level cache.
- Specified by:
setCacheModein interfaceSession- Parameters:
cacheMode- the new cache mode
-
setCacheRetrieveMode
public void setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode)
Description copied from interface:SessionEnable or disable reads from the second-level cache.- Specified by:
setCacheRetrieveModein interfaceSession- Parameters:
cacheRetrieveMode- a JPA-definedCacheRetrieveMode- See Also:
Session.setCacheMode(CacheMode)
-
setCacheStoreMode
public void setCacheStoreMode(CacheStoreMode cacheStoreMode)
Description copied from interface:SessionEnable or disable writes to the second-level cache.- Specified by:
setCacheStoreModein interfaceSession- Parameters:
cacheStoreMode- a JPA-definedCacheStoreMode- See Also:
Session.setCacheMode(CacheMode)
-
getCacheStoreMode
public CacheStoreMode getCacheStoreMode()
Description copied from interface:SessionThe JPA-definedCacheStoreMode.- Specified by:
getCacheStoreModein interfaceSession- See Also:
Session.getCacheMode()
-
getCacheRetrieveMode
public CacheRetrieveMode getCacheRetrieveMode()
Description copied from interface:SessionThe JPA-definedCacheRetrieveMode.- Specified by:
getCacheRetrieveModein interfaceSession- See Also:
Session.getCacheMode()
-
getCacheMode
public CacheMode getCacheMode()
Description copied from interface:SessionGet the currentcache modefor this session.- Specified by:
getCacheModein interfaceSession- Returns:
- the current cache mode
-
getSessionFactory
public SessionFactory getSessionFactory()
Description copied from interface:SessionGet the session factory which created this session.- Specified by:
getSessionFactoryin interfaceSession- Returns:
- the session factory
- See Also:
SessionFactory
-
cancelQuery
public void cancelQuery()
Description copied from interface:SessionCancel the execution of the current query.This is the sole method on session which may be safely called from another thread.
- Specified by:
cancelQueryin interfaceSession
-
isDirty
public boolean isDirty()
Description copied from interface:SessionDoes this session contain any changes which must be synchronized with the database? In other words, would any DML operations be executed if we flushed this session?
-
isDefaultReadOnly
public boolean isDefaultReadOnly()
Description copied from interface:SessionWill entities and proxies that are loaded into this session be made read-only by default?To determine the read-only/modifiable setting for a particular entity or proxy use
Session.isReadOnly(Object).- Specified by:
isDefaultReadOnlyin interfaceSession- Returns:
true, loaded entities/proxies will be made read-only by default;false, loaded entities/proxies will be made modifiable by default.- See Also:
Session.isReadOnly(Object)
-
setDefaultReadOnly
public void setDefaultReadOnly(boolean readOnly)
Description copied from interface:SessionChange the default for entities and proxies loaded into this session from modifiable to read-only mode, or from modifiable to read-only mode.Read-only entities are not dirty-checked and snapshots of persistent state are not maintained. Read-only entities can be modified, but changes are not persisted.
When a proxy is initialized, the loaded entity will have the same read-only/modifiable setting as the uninitialized proxy has, regardless of the session's current setting.
To change the read-only/modifiable setting for a particular entity or proxy that already belongs to this session use
Session.setReadOnly(Object, boolean).To override this session's read-only/modifiable setting for all entities and proxies loaded by a certain
QueryuseQuery.setReadOnly(boolean).- Specified by:
setDefaultReadOnlyin interfaceSession- Parameters:
readOnly-true, the default for loaded entities/proxies is read-only;false, the default for loaded entities/proxies is modifiable- See Also:
Session.setReadOnly(Object,boolean),Query.setReadOnly(boolean)
-
getIdentifier
public Object getIdentifier(Object object)
Description copied from interface:SessionReturn the identifier value of the given entity associated with this session. An exception is thrown if the given entity instance is transient or detached in relation to this session.- Specified by:
getIdentifierin interfaceSession- Parameters:
object- a persistent instance associated with this session- Returns:
- the identifier
-
contains
public boolean contains(String entityName, Object object)
Description copied from interface:SessionDetermine if the given entity is associated with this session.
-
detach
public void detach(Object object)
Description copied from interface:SessionRemove this instance from the session cache. Changes to the instance will not be synchronized with the database. This operation cascades to associated instances if the association is mapped withCascadeType.DETACH.- Specified by:
detachin interfaceEntityManager- Specified by:
detachin interfaceSession- Parameters:
object- the managed instance to detach
-
evict
public void evict(Object object)
Description copied from interface:SessionRemove this instance from the session cache. Changes to the instance will not be synchronized with the database. This operation cascades to associated instances if the association is mapped withCascadeType.DETACH.This operation is a synonym for
Session.detach(Object).
-
load
@Deprecated public <T> T load(Class<T> theClass, Object id, LockMode lockMode)
Deprecated.Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.Convenient form of
Session.load(Class, Object, LockOptions).- Specified by:
loadin interfaceSession- Parameters:
theClass- a persistent classid- a valid identifier of an existing persistent instance of the classlockMode- the lock level- Returns:
- the persistent instance or proxy
- See Also:
Session.load(Class, Object, LockOptions)
-
load
@Deprecated public <T> T load(Class<T> theClass, Object id, LockOptions lockOptions)
Deprecated.Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
-
load
@Deprecated public Object load(String entityName, Object id, LockMode lockMode)
Deprecated.Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.Convenient form of
Session.load(String, Object, LockOptions).- Specified by:
loadin interfaceSession- Parameters:
entityName- the entity nameid- a valid identifier of an existing persistent instance of the classlockMode- the lock level- Returns:
- the persistent instance or proxy
- See Also:
Session.load(String, Object, LockOptions)
-
load
@Deprecated public Object load(String entityName, Object id, LockOptions lockOptions)
Deprecated.Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
-
load
@Deprecated public <T> T load(Class<T> theClass, Object id)
Deprecated.Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, making the assumption that the instance exists in the database. This method might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed.You should not use this method to determine if an instance exists in the database (use
get()instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.This operation is very similar to
Session.getReference(Class, Object).
-
load
@Deprecated public Object load(String entityName, Object id)
Deprecated.Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, making the assumption that the instance exists in the database. This method might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed.You should not use this method to determine if an instance exists in the database (use
get()instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.
-
load
public void load(Object object, Object id)
Description copied from interface:SessionRead the persistent state associated with the given identifier into the given transient instance.
-
replicate
@Deprecated public void replicate(Object object, ReplicationMode replicationMode)
Deprecated.Description copied from interface:SessionPersist the state of the given detached instance, reusing the current identifier value. This operation cascades to associated instances if the association is mapped withCascadeType.REPLICATE.
-
replicate
@Deprecated public void replicate(String entityName, Object object, ReplicationMode replicationMode)
Deprecated.Description copied from interface:SessionPersist the state of the given detached instance, reusing the current identifier value. This operation cascades to associated instances if the association is mapped withCascadeType.REPLICATE.
-
save
@Deprecated public Object save(Object object)
Deprecated.Description copied from interface:SessionPersist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if theassignedgenerator is used.) This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE.This operation is very similar to
Session.persist(Object).
-
save
@Deprecated public Object save(String entityName, Object object)
Deprecated.Description copied from interface:SessionPersist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if theassignedgenerator is used.) This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE.
-
saveOrUpdate
@Deprecated public void saveOrUpdate(Object object)
Deprecated.Description copied from interface:SessionEitherSession.save(Object)orSession.update(Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking).This operation cascades to associated instances if the association is mapped with
CascadeType.SAVE_UPDATE.- Specified by:
saveOrUpdatein interfaceSession- Parameters:
object- a transient or detached instance containing new or updated state- See Also:
Session.save(Object),Session.update(Object object)
-
saveOrUpdate
@Deprecated public void saveOrUpdate(String entityName, Object object)
Deprecated.Description copied from interface:SessionEitherSession.save(String, Object)orSession.update(String, Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking).This operation cascades to associated instances if the association is mapped with
CascadeType.SAVE_UPDATE.- Specified by:
saveOrUpdatein interfaceSession- Parameters:
entityName- the entity nameobject- a transient or detached instance containing new or updated state- See Also:
Session.save(String,Object),Session.update(String,Object)
-
update
@Deprecated public void update(Object object)
Deprecated.Description copied from interface:SessionUpdate the persistent instance with the identifier of the given detached instance. If there is a persistent instance with the same identifier, an exception is thrown. This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE.
-
update
@Deprecated public void update(String entityName, Object object)
Deprecated.Description copied from interface:SessionUpdate the persistent instance with the identifier of the given detached instance. If there is a persistent instance with the same identifier, an exception is thrown. This operation cascades to associated instances if the association is mapped withCascadeType.SAVE_UPDATE.
-
merge
public <T> T merge(T object)
Description copied from interface:SessionCopy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved, save a copy and return it as a newly persistent instance. The given instance does not become associated with the session. This operation cascades to associated instances if the association is mapped withCascadeType.MERGE.- Specified by:
mergein interfaceEntityManager- Specified by:
mergein interfaceSession- Parameters:
object- a detached instance with state to be copied- Returns:
- an updated persistent instance
-
merge
public <T> T merge(String entityName, T object)
Description copied from interface:SessionCopy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved, save a copy and return it as a newly persistent instance. The given instance does not become associated with the session. This operation cascades to associated instances if the association is mapped withCascadeType.MERGE.
-
persist
public void persist(Object object)
Description copied from interface:SessionMake a transient instance persistent and mark it for later insertion in the database. This operation cascades to associated instances if the association is mapped withCascadeType.PERSIST.For entities with a
generated id,persist()ultimately results in generation of an identifier for the given instance. But this may happen asynchronously, when the session is flushed, depending on the identifier generation strategy.- Specified by:
persistin interfaceEntityManager- Specified by:
persistin interfaceSession- Parameters:
object- a transient instance to be made persistent
-
persist
public void persist(String entityName, Object object)
Description copied from interface:SessionMake a transient instance persistent and mark it for later insertion in the database. This operation cascades to associated instances if the association is mapped withCascadeType.PERSIST.For entities with a
generated id,persist()ultimately results in generation of an identifier for the given instance. But this may happen asynchronously, when the session is flushed, depending on the identifier generation strategy.
-
delete
@Deprecated public void delete(Object object)
Deprecated.Description copied from interface:SessionRemove a persistent instance from the datastore. The argument may be an instance associated with the receivingSessionor a transient instance with an identifier associated with existing persistent state. This operation cascades to associated instances if the association is mapped withCascadeType.REMOVE.
-
delete
@Deprecated public void delete(String entityName, Object object)
Deprecated.Description copied from interface:SessionRemove a persistent instance from the datastore. The second argument may be an instance associated with the receivingSessionor a transient instance with an identifier associated with existing persistent state. This operation cascades to associated instances if the association is mapped withCascadeType.REMOVE.
-
lock
public void lock(Object object, LockMode lockMode)
Description copied from interface:SessionObtain the specified lock level on the given managed instance associated with this session. This may be used to:- perform a version check with
LockMode.READ, or - upgrade to a pessimistic lock with
LockMode.PESSIMISTIC_WRITE).
This operation cascades to associated instances if the association is mapped with
CascadeType.LOCK. - perform a version check with
-
lock
@Deprecated public void lock(String entityName, Object object, LockMode lockMode)
Deprecated.Description copied from interface:SessionObtain the specified lock level on the given managed instance associated with this session. This may be used to:- perform a version check with
LockMode.READ, or - upgrade to a pessimistic lock with
LockMode.PESSIMISTIC_WRITE).
This operation cascades to associated instances if the association is mapped with
CascadeType.LOCK. - perform a version check with
-
lock
public void lock(Object object, LockOptions lockOptions)
Description copied from interface:SessionObtain a lock on the given managed instance associated with this session, using the givenlock options.This operation cascades to associated instances if the association is mapped with
CascadeType.LOCK.
-
buildLockRequest
@Deprecated public Session.LockRequest buildLockRequest(LockOptions lockOptions)
Deprecated.Description copied from interface:SessionBuild a newlock requestthat specifies:- the
LockModeto use, - the pessimistic lock timeout, and
- the scope that is, whether the lock extends to rows of owned collections.
Timeout and scope are ignored if the specified
LockModerepresents a flavor of optimistic locking.Call
Session.LockRequest.lock(Object)to actually obtain the requested lock on a managed entity instance.- Specified by:
buildLockRequestin interfaceSession- Parameters:
lockOptions- contains the lock level- Returns:
- a
Session.LockRequestthat can be used to lock any given object.
- the
-
refresh
public void refresh(Object object)
Description copied from interface:SessionReread the state of the given managed instance associated with this session from the underlying database. This may be useful:- when a database trigger alters the object state upon insert or update
- after executing any HQL update or delete statement
- after executing a native SQL statement
- after inserting a
BloborClob
This operation cascades to associated instances if the association is mapped with
CascadeType.REFRESH.This operation requests
LockMode.READ. To obtain a stronger lock, callSession.refresh(Object, LockMode).- Specified by:
refreshin interfaceEntityManager- Specified by:
refreshin interfaceSession- Parameters:
object- a persistent or detached instance
-
refresh
@Deprecated public void refresh(String entityName, Object object)
Deprecated.Description copied from interface:SessionReread the state of the given managed instance associated with this session from the underlying database. This may be useful:- when a database trigger alters the object state upon insert or update
- after executing any HQL update or delete statement
- after executing a native SQL statement
- after inserting a
BloborClob
This operation cascades to associated instances if the association is mapped with
CascadeType.REFRESH.
-
refresh
public void refresh(Object object, LockMode lockMode)
Description copied from interface:SessionReread the state of the given managed instance from the underlying database, obtaining the givenLockMode.Convenient form of
Session.refresh(Object, LockOptions)- Specified by:
refreshin interfaceSession- Parameters:
object- a persistent or detached instancelockMode- the lock mode to use- See Also:
Session.refresh(Object, LockOptions)
-
refresh
public void refresh(Object object, LockOptions lockOptions)
Description copied from interface:SessionReread the state of the given managed instance from the underlying database, obtaining the givenLockMode.
-
refresh
@Deprecated public void refresh(String entityName, Object object, LockOptions lockOptions)
Deprecated.Description copied from interface:SessionReread the state of the given managed instance from the underlying database, obtaining the givenLockMode.
-
remove
public void remove(Object object)
Description copied from interface:SessionMark a persistence instance associated with this session for removal from the underlying database. Ths operation cascades to associated instances if the association is mappedCascadeType.REMOVE.- Specified by:
removein interfaceEntityManager- Specified by:
removein interfaceSession- Parameters:
object- the managed persistent instance to remove
-
getCurrentLockMode
public LockMode getCurrentLockMode(Object object)
Description copied from interface:SessionDetermine the currentLockModeof the given managed instance associated with this session.- Specified by:
getCurrentLockModein interfaceSession- Parameters:
object- a persistent instance- Returns:
- the current lock mode
-
clear
public void clear()
Description copied from interface:SessionCompletely clear the session. Evict all loaded instances and cancel all pending saves, updates and deletions. Do not close open iterators or instances ofScrollableResults.- Specified by:
clearin interfaceEntityManager- Specified by:
clearin interfaceSession
-
get
public <T> T get(Class<T> entityType, Object id)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.This operation is very similar to
EntityManager.find(Class, Object).This operation requests
LockMode.NONE, that is, no lock, allowing the object to be retrieved from the cache without the cost of database access. However, if it is necessary to read the state from the database, the object will be returned with the lock modeLockMode.READ.To bypass the second-level cache, and ensure that the state is read from the database, either:
- call
Session.get(Class, Object, LockMode)with the explicit lock modeLockMode.READ, or - set the cache mode to
CacheMode.IGNOREbefore calling this method.
- call
-
get
public <T> T get(Class<T> entityType, Object id, LockMode lockMode)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance. Obtain the specified lock mode if the instance exists.Convenient form of
Session.get(Class, Object, LockOptions).This operation is very similar to
EntityManager.find(Class, Object, jakarta.persistence.LockModeType).- Specified by:
getin interfaceSession- Parameters:
entityType- the entity typeid- an identifierlockMode- the lock mode- Returns:
- a persistent instance or null
- See Also:
Session.get(Class, Object, LockOptions)
-
get
public <T> T get(Class<T> entityType, Object id, LockOptions lockOptions)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance. Obtain the specified lock mode if the instance exists.
-
get
public Object get(String entityName, Object id)
Description copied from interface:SessionReturn the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.
-
get
public Object get(String entityName, Object id, LockMode lockMode)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance. Obtain the specified lock mode if the instance exists.Convenient form of
Session.get(String, Object, LockOptions)- Specified by:
getin interfaceSession- Parameters:
entityName- the entity nameid- an identifierlockMode- the lock mode- Returns:
- a persistent instance or null
- See Also:
Session.get(String, Object, LockOptions)
-
get
public Object get(String entityName, Object id, LockOptions lockOptions)
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance. Obtain the specified lock mode if the instance exists.
-
getEntityName
public String getEntityName(Object object)
Description copied from interface:SessionReturn the entity name for a persistent entity.- Specified by:
getEntityNamein interfaceSession- Parameters:
object- a persistent entity associated with this session- Returns:
- the entity name
-
getReference
public <T> T getReference(Class<T> entityType, Object id)
Description copied from interface:SessionReturn a reference to the persistent instance with the given class and identifier, making the assumption that the instance is still persistent in the database. This method never results in access to the underlying data store, and thus might return a proxy that is initialized on-demand, when a non-identifier method is accessed.Note that
Hibernate.createDetachedProxy(SessionFactory, Class, Object)may be used to obtain a detached reference.- Specified by:
getReferencein interfaceEntityManager- Specified by:
getReferencein interfaceSession- Parameters:
entityType- the entity typeid- the identifier of a persistent instance that exists in the database- Returns:
- the persistent instance or proxy
-
getReference
public Object getReference(String entityName, Object id)
Description copied from interface:SessionReturn a reference to the persistent instance of the given named entity with the given identifier, making the assumption that the instance is still persistent in the database. This method never results in access to the underlying data store, and thus might return a proxy that is initialized on-demand, when a non-identifier method is accessed.- Specified by:
getReferencein interfaceSession- Parameters:
entityName- the entity nameid- the identifier of a persistent instance that exists in the database- Returns:
- the persistent instance or proxy
-
getReference
public <T> T getReference(T object)
Description copied from interface:SessionReturn a reference to the persistent instance with the same identity as the given instance, which might be detached, making the assumption that the instance is still persistent in the database. This method never results in access to the underlying data store, and thus might return a proxy that is initialized on-demand, when a non-identifier method is accessed.- Specified by:
getReferencein interfaceSession- Parameters:
object- a detached persistent instance- Returns:
- the persistent instance or proxy
-
byId
public <T> IdentifierLoadAccess<T> byId(String entityName)
Description copied from interface:SessionCreate anIdentifierLoadAccessinstance to retrieve the specified entity type by primary key.
-
byMultipleIds
public <T> MultiIdentifierLoadAccess<T> byMultipleIds(Class<T> entityClass)
Description copied from interface:SessionCreate aMultiIdentifierLoadAccessinstance to retrieve multiple entities at once as specified by primary key values.- Specified by:
byMultipleIdsin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by primary key values
-
byMultipleIds
public <T> MultiIdentifierLoadAccess<T> byMultipleIds(String entityName)
Description copied from interface:SessionCreate aMultiIdentifierLoadAccessinstance to retrieve multiple entities at once as specified by primary key values.- Specified by:
byMultipleIdsin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by primary key values
-
byId
public <T> IdentifierLoadAccess<T> byId(Class<T> entityClass)
Description copied from interface:SessionCreate anIdentifierLoadAccessinstance to retrieve the specified entity by primary key.
-
byNaturalId
public <T> NaturalIdLoadAccess<T> byNaturalId(String entityName)
Description copied from interface:SessionCreate aNaturalIdLoadAccessinstance to retrieve the specified entity by its natural id.- Specified by:
byNaturalIdin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by natural id
-
byNaturalId
public <T> NaturalIdLoadAccess<T> byNaturalId(Class<T> entityClass)
Description copied from interface:SessionCreate aNaturalIdLoadAccessinstance to retrieve the specified entity by its natural id.- Specified by:
byNaturalIdin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by natural id
-
bySimpleNaturalId
public <T> SimpleNaturalIdLoadAccess<T> bySimpleNaturalId(String entityName)
Description copied from interface:SessionCreate aSimpleNaturalIdLoadAccessinstance to retrieve the specified entity by itsnatural id.- Specified by:
bySimpleNaturalIdin interfaceSession- Parameters:
entityName- the entity name of the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by natural id
-
bySimpleNaturalId
public <T> SimpleNaturalIdLoadAccess<T> bySimpleNaturalId(Class<T> entityClass)
Description copied from interface:SessionCreate aSimpleNaturalIdLoadAccessinstance to retrieve the specified entity by its simple (single attribute)natural id.- Specified by:
bySimpleNaturalIdin interfaceSession- Parameters:
entityClass- the entity type to be retrieved- Returns:
- load delegate for loading the specified entity type by natural id
-
byMultipleNaturalId
public <T> NaturalIdMultiLoadAccess<T> byMultipleNaturalId(Class<T> entityClass)
Description copied from interface:SessionAccess to load multiple entities bynatural id.- Specified by:
byMultipleNaturalIdin interfaceSession
-
byMultipleNaturalId
public <T> NaturalIdMultiLoadAccess<T> byMultipleNaturalId(String entityName)
Description copied from interface:SessionAccess to load multiple entities bynatural id.- Specified by:
byMultipleNaturalIdin interfaceSession
-
enableFilter
public Filter enableFilter(String filterName)
Description copied from interface:SessionEnable the named filter for this current session.The returned
Filterobject must be used to bind arguments to parameters of the filter, and every parameter must be set before any other operation of this session is called.- Specified by:
enableFilterin interfaceSession- Parameters:
filterName- the name of the filter to be enabled.- Returns:
- the
Filterinstance representing the enabled filter. - See Also:
FilterDef
-
getEnabledFilter
public Filter getEnabledFilter(String filterName)
Description copied from interface:SessionRetrieve a currently enabled filter by name.- Specified by:
getEnabledFilterin interfaceSession- Parameters:
filterName- the name of the filter to be retrieved.- Returns:
- the
Filterinstance representing the enabled filter.
-
disableFilter
public void disableFilter(String filterName)
Description copied from interface:SessionDisable the named filter for the current session.- Specified by:
disableFilterin interfaceSession- Parameters:
filterName- the name of the filter to be disabled.
-
getStatistics
public SessionStatistics getStatistics()
Description copied from interface:SessionGet the statistics for this session.- Specified by:
getStatisticsin interfaceSession- Returns:
- the session statistics being collected for this session
-
isReadOnly
public boolean isReadOnly(Object entityOrProxy)
Description copied from interface:SessionIs the specified entity or proxy read-only?To get the default read-only/modifiable setting used for entities and proxies that are loaded into the session use
Session.isDefaultReadOnly()- Specified by:
isReadOnlyin interfaceSession- Parameters:
entityOrProxy- an entity or proxy- Returns:
trueif the entity or proxy is read-only,falseif the entity or proxy is modifiable.- See Also:
Session.isDefaultReadOnly()
-
setReadOnly
public void setReadOnly(Object entityOrProxy, boolean readOnly)
Description copied from interface:SessionSet an unmodified persistent object to read-only mode, or a read-only object to modifiable mode. In read-only mode, no snapshot is maintained, the instance is never dirty checked, and changes are not persisted.If the entity or proxy already has the specified read-only/modifiable setting, then this method does nothing.
To set the default read-only/modifiable setting used for all entities and proxies that are loaded into the session use
Session.setDefaultReadOnly(boolean).To override this session's read-only/modifiable setting for entities and proxies loaded by a
QueryuseQuery.setReadOnly(boolean)- Specified by:
setReadOnlyin interfaceSession- Parameters:
entityOrProxy- an entity or proxyreadOnly-trueif the entity or proxy should be made read-only;falseif the entity or proxy should be made modifiable- See Also:
Session.setDefaultReadOnly(boolean),Query.setReadOnly(boolean)
-
isFetchProfileEnabled
public boolean isFetchProfileEnabled(String name) throws UnknownProfileException
Description copied from interface:SessionIs thefetch profilewith the given name enabled in this session?- Specified by:
isFetchProfileEnabledin interfaceSession- Parameters:
name- the name of the profile- Returns:
- True if fetch profile is enabled; false if not.
- Throws:
UnknownProfileException- Indicates that the given name does not match any known fetch profile names- See Also:
FetchProfile
-
enableFetchProfile
public void enableFetchProfile(String name) throws UnknownProfileException
Description copied from interface:SessionEnable thefetch profilewith the given name in this session. If the requested fetch profile is already enabled, the call has no effect.- Specified by:
enableFetchProfilein interfaceSession- Parameters:
name- the name of the fetch profile to be enabled- Throws:
UnknownProfileException- Indicates that the given name does not match any known fetch profile names- See Also:
FetchProfile
-
disableFetchProfile
public void disableFetchProfile(String name) throws UnknownProfileException
Description copied from interface:SessionDisable thefetch profilewith the given name in this session. If the requested fetch profile is not currently enabled, the call has no effect.- Specified by:
disableFetchProfilein interfaceSession- Parameters:
name- the name of the fetch profile to be disabled- Throws:
UnknownProfileException- Indicates that the given name does not match any known fetch profile names- See Also:
FetchProfile
-
getLobHelper
public LobHelper getLobHelper()
Description copied from interface:Session- Specified by:
getLobHelperin interfaceSession- Returns:
- an instance of
LobHelper
-
sessionWithOptions
public SharedSessionBuilder sessionWithOptions()
Description copied from interface:SessionObtain aSessionbuilder with the ability to copy certain information from this session.- Specified by:
sessionWithOptionsin interfaceSession- Returns:
- the session builder
-
addEventListeners
public void addEventListeners(SessionEventListener... listeners)
Description copied from interface:SessionAdd one or more listeners to the Session- Specified by:
addEventListenersin interfaceSession- Parameters:
listeners- the listener(s) to add
-
createEntityGraph
public <T> RootGraph<T> createEntityGraph(Class<T> rootType)
- Specified by:
createEntityGraphin interfaceEntityManager- Specified by:
createEntityGraphin interfaceSession
-
createEntityGraph
public RootGraph<?> createEntityGraph(String graphName)
- Specified by:
createEntityGraphin interfaceEntityManager- Specified by:
createEntityGraphin interfaceSession
-
getEntityGraph
public RootGraph<?> getEntityGraph(String graphName)
- Specified by:
getEntityGraphin interfaceEntityManager- Specified by:
getEntityGraphin interfaceSession
-
getEntityGraphs
public <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass)
- Specified by:
getEntityGraphsin interfaceEntityManager- Specified by:
getEntityGraphsin interfaceSession
-
createQuery
public <R> Query<R> createQuery(String queryString, Class<R> resultClass)
Description copied from interface:QueryProducerCreate a typedQueryinstance for the given HQL query string.The returned
Querymay be executed by callingQuery.getResultList()orQuery.getSingleResult().- Specified by:
createQueryin interfaceEntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceSession- Parameters:
queryString- The HQL queryresultClass- The type of the query result- Returns:
- The Query instance for manipulation and execution
- See Also:
EntityManager.createQuery(String,Class)
-
createQuery
@Deprecated public Query createQuery(String queryString)
Deprecated.Description copied from interface:QueryProducerCreate aQueryinstance for the given HQL query, or HQL insert, update, or delete statement.- Specified by:
createQueryin interfaceEntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceSession- Parameters:
queryString- The HQL query- Returns:
- The
Queryinstance for manipulation and execution - See Also:
EntityManager.createQuery(String)
-
createNamedQuery
public <R> Query<R> createNamedQuery(String name, Class<R> resultClass)
Description copied from interface:QueryProducerCreate a typedQueryinstance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQueryin interfaceEntityManager- Specified by:
createNamedQueryin interfaceQueryProducer- Specified by:
createNamedQueryin interfaceSession- Parameters:
name- the name of a query defined in metadataresultClass- the type of the query result- Returns:
- The
Queryinstance for manipulation and execution - See Also:
EntityManager.createNamedQuery(String,Class)
-
createNamedQuery
@Deprecated public Query createNamedQuery(String name)
Deprecated.Description copied from interface:QueryProducerCreate a typedQueryinstance for the given named query. The named query might be defined in HQL or in native SQL.- Specified by:
createNamedQueryin interfaceEntityManager- Specified by:
createNamedQueryin interfaceQueryProducer- Specified by:
createNamedQueryin interfaceSession- Parameters:
name- the name of a pre-defined, named query- Returns:
- The
Queryinstance for manipulation and execution - See Also:
EntityManager.createNamedQuery(String)
-
createQuery
public <R> Query<R> createQuery(CriteriaQuery<R> criteriaQuery)
Description copied from interface:QueryProducerCreate aQueryfor the given JPACriteriaQuery.- Specified by:
createQueryin interfaceEntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceSession
-
createQuery
@Deprecated public Query createQuery(CriteriaDelete deleteQuery)
Deprecated.Description copied from interface:SessionCreate aQueryfor the given JPACriteriaDelete.- Specified by:
createQueryin interfaceEntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceSession
-
createQuery
@Deprecated public Query createQuery(CriteriaUpdate updateQuery)
Deprecated.Description copied from interface:SessionCreate aQueryfor the given JPACriteriaUpdate.- Specified by:
createQueryin interfaceEntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceSession
-
getTenantIdentifier
public String getTenantIdentifier()
Description copied from interface:SharedSessionContractObtain the tenant identifier associated with this session.- Specified by:
getTenantIdentifierin interfaceSharedSessionContract- Returns:
- The tenant identifier associated with this session, or
null
-
close
public void close() throws HibernateExceptionDescription copied from interface:SharedSessionContractEnd the session by releasing the JDBC connection and cleaning up.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceEntityManager- Specified by:
closein interfaceSharedSessionContract- Throws:
HibernateException- Indicates problems cleaning up.
-
isOpen
public boolean isOpen()
Description copied from interface:SharedSessionContractCheck if the session is still open.- Specified by:
isOpenin interfaceEntityManager- Specified by:
isOpenin interfaceSharedSessionContract- Returns:
- boolean
-
isConnected
public boolean isConnected()
Description copied from interface:SharedSessionContractCheck if the session is currently connected.- Specified by:
isConnectedin interfaceSharedSessionContract- Returns:
- boolean
-
beginTransaction
public Transaction beginTransaction()
Description copied from interface:SharedSessionContractBegin a unit of work and return the associatedTransactionobject. If a new underlying transaction is required, begin the transaction. Otherwise, continue the new work in the context of the existing underlying transaction.- Specified by:
beginTransactionin interfaceSharedSessionContract- Returns:
- a
Transactioninstance - See Also:
SharedSessionContract.getTransaction()
-
getTransaction
public Transaction getTransaction()
Description copied from interface:SharedSessionContractGet theTransactioninstance associated with this session.- Specified by:
getTransactionin interfaceEntityManager- Specified by:
getTransactionin interfaceSharedSessionContract- Returns:
- a Transaction instance
- See Also:
EntityManager.getTransaction()
-
getNamedProcedureCall
public ProcedureCall getNamedProcedureCall(String name)
Description copied from interface:SharedSessionContractObtain aProcedureCallbased on a named template- Specified by:
getNamedProcedureCallin interfaceSharedSessionContract- Parameters:
name- The name given to the template- Returns:
- The ProcedureCall
- See Also:
NamedStoredProcedureQuery
-
createStoredProcedureCall
public ProcedureCall createStoredProcedureCall(String procedureName)
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure.- Specified by:
createStoredProcedureCallin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
public ProcedureCall createStoredProcedureCall(String procedureName, Class<?>... resultClasses)
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureCallin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.resultClasses- The entity(s) to map the result on to.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
public ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings)
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureCallin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.resultSetMappings- The explicit result set mapping(s) to use for mapping the results- Returns:
- The representation of the procedure call.
-
createNamedStoredProcedureQuery
public ProcedureCall createNamedStoredProcedureQuery(String name)
Description copied from interface:SharedSessionContractObtain aProcedureCallbased on a named template- Specified by:
createNamedStoredProcedureQueryin interfaceEntityManager- Specified by:
createNamedStoredProcedureQueryin interfaceSharedSessionContract- Parameters:
name- The name given to the template- Returns:
- The ProcedureCall
- See Also:
NamedStoredProcedureQuery
-
createStoredProcedureQuery
public ProcedureCall createStoredProcedureQuery(String procedureName)
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure.- Specified by:
createStoredProcedureQueryin interfaceEntityManager- Specified by:
createStoredProcedureQueryin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
public ProcedureCall createStoredProcedureQuery(String procedureName, Class... resultClasses)
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings. Each given class is considered a "root return".- Specified by:
createStoredProcedureQueryin interfaceEntityManager- Specified by:
createStoredProcedureQueryin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.resultClasses- The entity(s) to map the result on to.- Returns:
- The representation of the procedure call.
-
createStoredProcedureQuery
public ProcedureCall createStoredProcedureQuery(String procedureName, String... resultSetMappings)
Description copied from interface:SharedSessionContractCreate aProcedureCallto a stored procedure with the given result set entity mappings.- Specified by:
createStoredProcedureQueryin interfaceEntityManager- Specified by:
createStoredProcedureQueryin interfaceSharedSessionContract- Parameters:
procedureName- The name of the procedure.resultSetMappings- The explicit result set mapping(s) to use for mapping the results- Returns:
- The representation of the procedure call.
-
getJdbcBatchSize
public Integer getJdbcBatchSize()
Description copied from interface:SharedSessionContractGet the session-level JDBC batch size for the current session.- Specified by:
getJdbcBatchSizein interfaceSharedSessionContract- Returns:
- the current session-level JDBC batch size
- See Also:
SessionFactoryOptions.getJdbcBatchSize(),SessionFactoryBuilder.applyJdbcBatchSize(int)
-
setJdbcBatchSize
public void setJdbcBatchSize(Integer jdbcBatchSize)
Description copied from interface:SharedSessionContractSet the session-level JDBC batch size. Overrides thefactory-levelJDBC batch size defined by the configuration property "hibernate.jdbc.batch_size".- Specified by:
setJdbcBatchSizein interfaceSharedSessionContract- Parameters:
jdbcBatchSize- the new session-level JDBC batch size- See Also:
SessionFactoryOptions.getJdbcBatchSize(),SessionFactoryBuilder.applyJdbcBatchSize(int)
-
getCriteriaBuilder
public HibernateCriteriaBuilder getCriteriaBuilder()
Description copied from interface:SharedSessionContract- Specified by:
getCriteriaBuilderin interfaceEntityManager- Specified by:
getCriteriaBuilderin interfaceSharedSessionContract- Returns:
- an instance of
HibernateCriteriaBuilder - See Also:
SessionFactory.getCriteriaBuilder()
-
doWork
public void doWork(Work work) throws HibernateException
Description copied from interface:SharedSessionContractPerform work using theConnectionunderlying by this session.- Specified by:
doWorkin interfaceSharedSessionContract- Parameters:
work- The work to be performed.- Throws:
HibernateException- Generally indicates wrappedSQLException
-
doReturningWork
public <T> T doReturningWork(ReturningWork<T> work) throws HibernateException
Description copied from interface:SharedSessionContractPerform work using theConnectionunderlying by this session, and return a result.- Specified by:
doReturningWorkin interfaceSharedSessionContract- Type Parameters:
T- The type of the result returned from the work- Parameters:
work- The work to be performed.- Returns:
- the result of calling
ReturningWork.execute(java.sql.Connection). - Throws:
HibernateException- Generally indicates wrappedSQLException
-
createNativeQuery
@Deprecated public NativeQuery createNativeQuery(String sqlString)
Deprecated.Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query.- Specified by:
createNativeQueryin interfaceEntityManager- Specified by:
createNativeQueryin interfaceQueryProducer- Parameters:
sqlString- a native SQL query string- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String)
-
createNativeQuery
public NativeQuery createNativeQuery(String sqlString, Class resultClass)
Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query using implicit mapping to the specified Java type.If the given class is an entity class, this method is equivalent to
createNativeQuery(sqlString).addEntity("alias1", resultClass).- Specified by:
createNativeQueryin interfaceEntityManager- Specified by:
createNativeQueryin interfaceQueryProducer- Parameters:
sqlString- The native (SQL) query stringresultClass- The Java entity type to map results to- Returns:
- The NativeQuery instance for manipulation and execution
- See Also:
EntityManager.createNativeQuery(String,Class)
-
createNativeQuery
public <R> NativeQuery<R> createNativeQuery(String sqlString, Class<R> resultClass, String tableAlias)
Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query using implicit mapping to the specified Java type.If the given class is an entity class, this method is equivalent to
createNativeQuery(sqlString).addEntity(tableAlias, resultClass).- Specified by:
createNativeQueryin interfaceQueryProducer- Parameters:
sqlString- Native (SQL) query stringresultClass- The Java entity type to map results totableAlias- The table alias for columns in the result set- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String,Class)
-
createNativeQuery
@Deprecated public NativeQuery createNativeQuery(String sqlString, String resultSetMappingName)
Deprecated.Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query using an explicit mapping to the specified Java type.The given result set mapping name must identify a mapping defined by a
SqlResultSetMappingannotation.- Specified by:
createNativeQueryin interfaceEntityManager- Specified by:
createNativeQueryin interfaceQueryProducer- Parameters:
sqlString- The native (SQL) query stringresultSetMappingName- The explicit result mapping name- Returns:
- The NativeQuery instance for manipulation and execution
- See Also:
EntityManager.createNativeQuery(String,Class),SqlResultSetMapping
-
createNativeQuery
public <R> NativeQuery<R> createNativeQuery(String sqlString, String resultSetMappingName, Class<R> resultClass)
Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL query using an explicit mapping to the specified Java type.The given result set mapping name must identify a mapping defined by a
SqlResultSetMappingannotation.- Specified by:
createNativeQueryin interfaceQueryProducer- Parameters:
sqlString- The native (SQL) query stringresultSetMappingName- The explicit result mapping name- Returns:
- The
NativeQueryinstance for manipulation and execution - See Also:
EntityManager.createNativeQuery(String,Class),SqlResultSetMapping
-
createSelectionQuery
public SelectionQuery<?> createSelectionQuery(String hqlString)
Description copied from interface:QueryProducerCreate aSelectionQueryreference for the given HQL. Only valid for select queries- Specified by:
createSelectionQueryin interfaceQueryProducer- See Also:
EntityManager.createQuery(String)
-
createSelectionQuery
public <R> SelectionQuery<R> createSelectionQuery(String hqlString, Class<R> resultType)
Description copied from interface:QueryProducerCreate aSelectionQueryreference for the given HQL. Only valid for select queries- Specified by:
createSelectionQueryin interfaceQueryProducer- See Also:
EntityManager.createQuery(String)
-
createSelectionQuery
public <R> SelectionQuery<R> createSelectionQuery(CriteriaQuery<R> criteria)
Description copied from interface:QueryProducerCreate aSelectionQueryreference for the given Criteria.- Specified by:
createSelectionQueryin interfaceQueryProducer- See Also:
EntityManager.createQuery(CriteriaQuery)
-
createMutationQuery
public MutationQuery createMutationQuery(String hqlString)
Description copied from interface:QueryProducerCreate a MutationQuery reference for the given HQL insert, update, or delete statement.- Specified by:
createMutationQueryin interfaceQueryProducer
-
createMutationQuery
public MutationQuery createMutationQuery(CriteriaUpdate updateQuery)
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given update criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer
-
createMutationQuery
public MutationQuery createMutationQuery(CriteriaDelete deleteQuery)
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given delete criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer
-
createMutationQuery
public MutationQuery createMutationQuery(JpaCriteriaInsertSelect insertSelect)
Description copied from interface:QueryProducerCreate aMutationQueryfrom the given insert-select criteria tree- Specified by:
createMutationQueryin interfaceQueryProducer
-
createNativeMutationQuery
public MutationQuery createNativeMutationQuery(String sqlString)
Description copied from interface:QueryProducerCreate aNativeQueryinstance for the given native SQL statement.- Specified by:
createNativeMutationQueryin interfaceQueryProducer- Parameters:
sqlString- a native SQL statement string- Returns:
- The NativeQuery instance for manipulation and execution
-
createNamedSelectionQuery
public SelectionQuery<?> createNamedSelectionQuery(String name)
Description copied from interface:QueryProducerCreate aSelectionQueryinstance for the namedNamedQuery- Specified by:
createNamedSelectionQueryin interfaceQueryProducer
-
createNamedSelectionQuery
public <R> SelectionQuery<R> createNamedSelectionQuery(String name, Class<R> resultType)
Description copied from interface:QueryProducerCreate aSelectionQueryinstance for the namedNamedQuerywith the expected result-type- Specified by:
createNamedSelectionQueryin interfaceQueryProducer
-
createNamedMutationQuery
public MutationQuery createNamedMutationQuery(String name)
Description copied from interface:QueryProducerCreate aMutationQueryinstance for the given named insert, update, or delete HQL query. The named query might be defined as HQL) or native-SQL.- Specified by:
createNamedMutationQueryin interfaceQueryProducer
-
getNamedQuery
@Deprecated public Query getNamedQuery(String queryName)
Deprecated.Description copied from interface:QueryProducerCreate aQueryinstance for the named query.- Specified by:
getNamedQueryin interfaceQueryProducer- Parameters:
queryName- the name of a pre-defined, named query- Returns:
- The
Queryinstance for manipulation and execution
-
getNamedNativeQuery
@Deprecated public NativeQuery getNamedNativeQuery(String name)
Deprecated.Description copied from interface:QueryProducerGet aNativeQueryinstance for a named native SQL query- Specified by:
getNamedNativeQueryin interfaceQueryProducer- Parameters:
name- The name of the pre-defined query- Returns:
- The
NativeQueryinstance for manipulation and execution
-
getNamedNativeQuery
@Deprecated public NativeQuery getNamedNativeQuery(String name, String resultSetMapping)
Deprecated.Description copied from interface:QueryProducerGet aNativeQueryinstance for a named native SQL query- Specified by:
getNamedNativeQueryin interfaceQueryProducer- Parameters:
name- The name of the pre-defined query- Returns:
- The
NativeQueryinstance for manipulation and execution
-
find
public <T> T find(Class<T> entityClass, Object primaryKey)
- Specified by:
findin interfaceEntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, Map<String,Object> properties)
- Specified by:
findin interfaceEntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockMode)
- Specified by:
findin interfaceEntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockMode, Map<String,Object> properties)
- Specified by:
findin interfaceEntityManager
-
lock
public void lock(Object entity, LockModeType lockMode)
- Specified by:
lockin interfaceEntityManager
-
lock
public void lock(Object entity, LockModeType lockMode, Map<String,Object> properties)
- Specified by:
lockin interfaceEntityManager
-
refresh
public void refresh(Object entity, Map<String,Object> properties)
- Specified by:
refreshin interfaceEntityManager
-
refresh
public void refresh(Object entity, LockModeType lockMode)
- Specified by:
refreshin interfaceEntityManager
-
refresh
public void refresh(Object entity, LockModeType lockMode, Map<String,Object> properties)
- Specified by:
refreshin interfaceEntityManager
-
contains
public boolean contains(Object entity)
- Specified by:
containsin interfaceEntityManager
-
getLockMode
public LockModeType getLockMode(Object entity)
- Specified by:
getLockModein interfaceEntityManager
-
setProperty
public void setProperty(String propertyName, Object value)
- Specified by:
setPropertyin interfaceEntityManager
-
getProperties
public Map<String,Object> getProperties()
- Specified by:
getPropertiesin interfaceEntityManager
-
joinTransaction
public void joinTransaction()
Description copied from interface:SharedSessionContractJoin the currently-active JTA transaction.- Specified by:
joinTransactionin interfaceEntityManager- Specified by:
joinTransactionin interfaceSharedSessionContract- See Also:
EntityManager.joinTransaction()
-
isJoinedToTransaction
public boolean isJoinedToTransaction()
Description copied from interface:SharedSessionContractCheck if the session is joined to the current transaction.- Specified by:
isJoinedToTransactionin interfaceEntityManager- Specified by:
isJoinedToTransactionin interfaceSharedSessionContract- See Also:
SharedSessionContract.joinTransaction(),EntityManager.isJoinedToTransaction()
-
unwrap
public <T> T unwrap(Class<T> cls)
- Specified by:
unwrapin interfaceEntityManager
-
getDelegate
public Object getDelegate()
- Specified by:
getDelegatein interfaceEntityManager
-
getEntityManagerFactory
public EntityManagerFactory getEntityManagerFactory()
- Specified by:
getEntityManagerFactoryin interfaceEntityManager
-
getMetamodel
public Metamodel getMetamodel()
- Specified by:
getMetamodelin interfaceEntityManager
-
-