Package org.hibernate.engine.spi
Class SessionLazyDelegator
- java.lang.Object
-
- org.hibernate.engine.spi.SessionLazyDelegator
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Serializable,java.lang.AutoCloseable,EntityManager,HibernateEntityManager,QueryProducer,Session,SharedSessionContract
public class SessionLazyDelegator extends java.lang.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(java.util.function.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)Build a LockRequest that specifies the LockMode, pessimistic lock timeout and lock scope.<T> IdentifierLoadAccess<T>byId(java.lang.Class<T> entityClass)Create anIdentifierLoadAccessinstance to retrieve the specified entity by primary key.IdentifierLoadAccessbyId(java.lang.String entityName)Create anIdentifierLoadAccessinstance to retrieve the specified entity type by primary key.<T> MultiIdentifierLoadAccess<T>byMultipleIds(java.lang.Class<T> entityClass)Create aMultiIdentifierLoadAccessinstance to retrieve multiple entities at once as specified by primary key values.MultiIdentifierLoadAccessbyMultipleIds(java.lang.String entityName)Create aMultiIdentifierLoadAccessinstance to retrieve multiple entities at once as specified by primary key values.<T> NaturalIdLoadAccess<T>byNaturalId(java.lang.Class<T> entityClass)Create aNaturalIdLoadAccessinstance to retrieve the specified entity by its natural id.NaturalIdLoadAccessbyNaturalId(java.lang.String entityName)Create aNaturalIdLoadAccessinstance to retrieve the specified entity by its natural id.<T> SimpleNaturalIdLoadAccess<T>bySimpleNaturalId(java.lang.Class<T> entityClass)Create aSimpleNaturalIdLoadAccessinstance to retrieve the specified entity by its simple (single attribute) natural id.SimpleNaturalIdLoadAccessbySimpleNaturalId(java.lang.String entityName)Create aSimpleNaturalIdLoadAccessinstance to retrieve the specified entity by its natural 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(java.lang.Object entity)booleancontains(java.lang.String entityName, java.lang.Object object)Check if this entity is associated with this Session.CriteriacreateCriteria(java.lang.Class persistentClass)Deprecated.CriteriacreateCriteria(java.lang.Class persistentClass, java.lang.String alias)Deprecated.CriteriacreateCriteria(java.lang.String entityName)Deprecated.CriteriacreateCriteria(java.lang.String entityName, java.lang.String alias)Deprecated.<T> RootGraph<T>createEntityGraph(java.lang.Class<T> rootType)RootGraph<?>createEntityGraph(java.lang.String graphName)QuerycreateFilter(java.lang.Object collection, java.lang.String queryString)Deprecated.QuerycreateNamedQuery(java.lang.String name)The JPA-defined named query creation method.<T> Query<T>createNamedQuery(java.lang.String name, java.lang.Class<T> resultType)The JPA-defined named, typed query creation method.StoredProcedureQuerycreateNamedStoredProcedureQuery(java.lang.String name)NativeQuerycreateNativeQuery(java.lang.String sqlString)Create a NativeQuery instance for the given native (SQL) queryNativeQuerycreateNativeQuery(java.lang.String sqlString, java.lang.Class resultClass)Create a NativeQuery instance for the given native (SQL) query using implicit mapping to the specified Java type.NativeQuerycreateNativeQuery(java.lang.String sqlString, java.lang.String resultSetMapping)Create a NativeQuery instance for the given native (SQL) query using implicit mapping to the specified Java type.QuerycreateQuery(java.lang.String queryString)Create aQueryinstance for the given HQL/JPQL query string.<T> Query<T>createQuery(java.lang.String queryString, java.lang.Class<T> resultType)Create a typedQueryinstance for the given HQL/JPQL query string.QuerycreateQuery(CriteriaDelete deleteQuery)<T> Query<T>createQuery(CriteriaQuery<T> criteriaQuery)QuerycreateQuery(CriteriaUpdate updateQuery)NativeQuerycreateSQLQuery(java.lang.String queryString)Create aNativeQueryinstance for the given SQL query string.ProcedureCallcreateStoredProcedureCall(java.lang.String procedureName)Creates a call to a stored procedure.ProcedureCallcreateStoredProcedureCall(java.lang.String procedureName, java.lang.Class... resultClasses)Creates a call to a stored procedure with specific result set entity mappings.ProcedureCallcreateStoredProcedureCall(java.lang.String procedureName, java.lang.String... resultSetMappings)Creates a call to a stored procedure with specific result set entity mappings.StoredProcedureQuerycreateStoredProcedureQuery(java.lang.String procedureName)StoredProcedureQuerycreateStoredProcedureQuery(java.lang.String procedureName, java.lang.Class... resultClasses)StoredProcedureQuerycreateStoredProcedureQuery(java.lang.String procedureName, java.lang.String... resultSetMappings)voiddelete(java.lang.Object object)Remove a persistent instance from the datastore.voiddelete(java.lang.String entityName, java.lang.Object object)Remove a persistent instance from the datastore.voiddetach(java.lang.Object entity)voiddisableFetchProfile(java.lang.String name)Disable a particular fetch profile on this session.voiddisableFilter(java.lang.String filterName)Disable the named filter for the current session.java.sql.Connectiondisconnect()Disconnect the session from its underlying JDBC connection.<T> TdoReturningWork(ReturningWork<T> work)Controller for allowing users to perform JDBC related work using the Connection managed by this Session.voiddoWork(Work work)Controller for allowing users to perform JDBC related work using the Connection managed by this Session.voidenableFetchProfile(java.lang.String name)Enable a particular fetch profile on this session.FilterenableFilter(java.lang.String filterName)Enable the named filter for this current session.voidevict(java.lang.Object object)Remove this instance from the session cache.<T> Tfind(java.lang.Class<T> entityClass, java.lang.Object primaryKey)<T> Tfind(java.lang.Class<T> entityClass, java.lang.Object primaryKey, java.util.Map<java.lang.String,java.lang.Object> properties)<T> Tfind(java.lang.Class<T> entityClass, java.lang.Object primaryKey, LockModeType lockMode)<T> Tfind(java.lang.Class<T> entityClass, java.lang.Object primaryKey, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)voidflush()Force this session to flush.<T> Tget(java.lang.Class<T> entityType, java.io.Serializable 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(java.lang.Class<T> entityType, java.io.Serializable 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(java.lang.Class<T> entityType, java.io.Serializable 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.java.lang.Objectget(java.lang.String entityName, java.io.Serializable id)Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance.java.lang.Objectget(java.lang.String entityName, java.io.Serializable 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.java.lang.Objectget(java.lang.String entityName, java.io.Serializable 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 current cache mode.CriteriaBuildergetCriteriaBuilder()LockModegetCurrentLockMode(java.lang.Object object)Determine the current lock mode of the given object.java.lang.ObjectgetDelegate()FiltergetEnabledFilter(java.lang.String filterName)Retrieve a currently enabled filter by name.RootGraph<?>getEntityGraph(java.lang.String graphName)<T> java.util.List<EntityGraph<? super T>>getEntityGraphs(java.lang.Class<T> entityClass)EntityManagerFactorygetEntityManagerFactory()java.lang.StringgetEntityName(java.lang.Object object)Return the entity name for a persistent entity.FlushModeTypegetFlushMode()FlushModegetHibernateFlushMode()Get the current flush mode for this session.java.io.SerializablegetIdentifier(java.lang.Object object)Return the identifier value of the given entity as associated with this session.java.lang.IntegergetJdbcBatchSize()Get the Session-level JDBC batch size for the current Session.LobHelpergetLobHelper()Retrieve this session's helper/delegate for creating LOB instances.LockModeTypegetLockMode(java.lang.Object entity)MetamodelgetMetamodel()NativeQuerygetNamedNativeQuery(java.lang.String name)Get a NativeQuery instance for a named native SQL queryProcedureCallgetNamedProcedureCall(java.lang.String name)Gets a ProcedureCall based on a named templateQuerygetNamedQuery(java.lang.String queryName)Create aQueryinstance for the named query.QuerygetNamedSQLQuery(java.lang.String name)Deprecated.java.util.Map<java.lang.String,java.lang.Object>getProperties()<T> TgetReference(java.lang.Class<T> entityClass, java.lang.Object primaryKey)<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.SessiongetSession()Retrieve a reference to the HibernateSessionused by thisEntityManager.SessionFactorygetSessionFactory()Get the session factory which created this session.SessionStatisticsgetStatistics()Get the statistics for this session.java.lang.StringgetTenantIdentifier()Obtain the tenant identifier associated with this session.TransactiongetTransaction()Get theTransactioninstance associated with this session.TypeHelpergetTypeHelper()Convenience access to theTypeHelperassociated with this session'sSessionFactory.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? To determine the read-only/modifiable setting for a particular entity or proxy: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(java.lang.String name)Is a particular fetch profile enabled on this session?booleanisJoinedToTransaction()booleanisOpen()Check if the session is still open.booleanisReadOnly(java.lang.Object entityOrProxy)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:voidjoinTransaction()<T> Tload(java.lang.Class<T> theClass, java.io.Serializable id)Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.<T> Tload(java.lang.Class<T> theClass, java.io.Serializable id, LockMode lockMode)Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.<T> Tload(java.lang.Class<T> theClass, java.io.Serializable id, LockOptions lockOptions)Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.voidload(java.lang.Object object, java.io.Serializable id)Read the persistent state associated with the given identifier into the given transient instance.java.lang.Objectload(java.lang.String entityName, java.io.Serializable id)Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.java.lang.Objectload(java.lang.String entityName, java.io.Serializable id, LockMode lockMode)Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.java.lang.Objectload(java.lang.String entityName, java.io.Serializable id, LockOptions lockOptions)Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.voidlock(java.lang.Object entity, LockModeType lockMode)voidlock(java.lang.Object entity, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)voidlock(java.lang.Object object, LockMode lockMode)Obtain the specified lock level upon the given object.voidlock(java.lang.String entityName, java.lang.Object object, LockMode lockMode)Obtain the specified lock level upon the given object.java.lang.Objectmerge(java.lang.Object object)Copy the state of the given object onto the persistent object with the same identifier.java.lang.Objectmerge(java.lang.String entityName, java.lang.Object object)Copy the state of the given object onto the persistent object with the same identifier.voidpersist(java.lang.Object object)Make a transient instance persistent.voidpersist(java.lang.String entityName, java.lang.Object object)Make a transient instance persistent.voidreconnect(java.sql.Connection connection)Reconnect to the given JDBC connection.voidrefresh(java.lang.Object object)Re-read the state of the given instance from the underlying database.voidrefresh(java.lang.Object entity, java.util.Map<java.lang.String,java.lang.Object> properties)voidrefresh(java.lang.Object entity, LockModeType lockMode)voidrefresh(java.lang.Object entity, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)voidrefresh(java.lang.Object object, LockMode lockMode)Re-read the state of the given instance from the underlying database, with the given LockMode.voidrefresh(java.lang.Object object, LockOptions lockOptions)Re-read the state of the given instance from the underlying database, with the given LockMode.voidrefresh(java.lang.String entityName, java.lang.Object object)Re-read the state of the given instance from the underlying database.voidrefresh(java.lang.String entityName, java.lang.Object object, LockOptions lockOptions)Re-read the state of the given instance from the underlying database, with the given LockMode.voidremove(java.lang.Object entity)voidreplicate(java.lang.Object object, ReplicationMode replicationMode)Persist the state of the given detached instance, reusing the current identifier value.voidreplicate(java.lang.String entityName, java.lang.Object object, ReplicationMode replicationMode)Persist the state of the given detached instance, reusing the current identifier value.java.io.Serializablesave(java.lang.Object object)Persist the given transient instance, first assigning a generated identifier.java.io.Serializablesave(java.lang.String entityName, java.lang.Object object)Persist the given transient instance, first assigning a generated identifier.voidsaveOrUpdate(java.lang.Object object)EitherSession.save(Object)orSession.update(Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking).voidsaveOrUpdate(java.lang.String entityName, java.lang.Object object)EitherSession.save(String, Object)orSession.update(String, Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking).SharedSessionBuildersessionWithOptions()Obtain aSessionbuilder with the ability to grab certain information from this session.voidsetCacheMode(CacheMode cacheMode)Set the cache mode.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)voidsetFlushMode(FlushMode flushMode)Deprecated.voidsetHibernateFlushMode(FlushMode flushMode)Set the flush mode for this session.voidsetJdbcBatchSize(java.lang.Integer jdbcBatchSize)Set the Session-level JDBC batch size.voidsetProperty(java.lang.String propertyName, java.lang.Object value)voidsetReadOnly(java.lang.Object entityOrProxy, boolean readOnly)Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode.<T> Tunwrap(java.lang.Class<T> cls)voidupdate(java.lang.Object object)Update the persistent instance with the identifier of the given detached instance.voidupdate(java.lang.String entityName, java.lang.Object object)Update the persistent instance with the identifier of the given detached instance.
-
-
-
Constructor Detail
-
SessionLazyDelegator
public SessionLazyDelegator(java.util.function.Supplier<Session> lazySessionLookup)
-
-
Method Detail
-
sessionWithOptions
public SharedSessionBuilder sessionWithOptions()
Description copied from interface:SessionObtain aSessionbuilder with the ability to grab certain information from this session.- Specified by:
sessionWithOptionsin interfaceSession- Returns:
- The session builder
-
flush
public void flush() throws HibernateExceptionDescription copied from interface:SessionForce this session to flush. Must be called at the end of a unit of work, before committing the transaction and closing the session (depending onSession.setFlushMode(FlushMode),EntityTransaction.commit()calls this method). Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.- Specified by:
flushin interfaceEntityManager- Specified by:
flushin interfaceSession- Throws:
HibernateException- Indicates problems flushing the session or talking to the database.
-
setFlushMode
@Deprecated public void setFlushMode(FlushMode flushMode)
Deprecated.Description copied from interface:SessionSet the flush mode for this session. The flush mode determines the points at which the session is flushed. Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory. For a logically "read only" session, it is reasonable to set the session's flush mode toFlushMode.MANUALat the start of the session (in order to achieve some extra performance).- Specified by:
setFlushModein interfaceSession- Parameters:
flushMode- the new flush mode
-
getFlushMode
public FlushModeType getFlushMode()
Description copied from interface:SessionFor users of the Hibernate native APIs, we've had to rename this method as defined by Hibernate historically because the JPA contract defines a method of the same name, but returning the JPAFlushModeTyperather than Hibernate'sFlushMode. For the former behavior, useSession.getHibernateFlushMode()instead.- Specified by:
getFlushModein interfaceEntityManager- Specified by:
getFlushModein interfaceSession- Returns:
- The FlushModeType in effect for this Session.
-
setHibernateFlushMode
public void setHibernateFlushMode(FlushMode flushMode)
Description copied from interface:SessionSet the flush mode for this session. The flush mode determines the points at which the session is flushed. Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory. For a logically "read only" session, it is reasonable to set the session's flush mode toFlushMode.MANUALat the start of the session (in order to achieve some extra performance).- Specified by:
setHibernateFlushModein interfaceSession- Parameters:
flushMode- the new flush mode
-
getHibernateFlushMode
public FlushMode getHibernateFlushMode()
Description copied from interface:SessionGet the current flush mode for this session.- Specified by:
getHibernateFlushModein interfaceSession- Returns:
- The flush mode
-
setCacheMode
public void setCacheMode(CacheMode cacheMode)
Description copied from interface:SessionSet the cache mode. 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.
-
getCacheMode
public CacheMode getCacheMode()
Description copied from interface:SessionGet the current cache mode.- 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() throws HibernateExceptionDescription copied from interface:SessionCancel the execution of the current query. This is the sole method on session which may be safely called from another thread.- Specified by:
cancelQueryin interfaceSession- Throws:
HibernateException- There was a problem canceling the query
-
isDirty
public boolean isDirty() throws HibernateExceptionDescription copied from interface:SessionDoes this session contain any changes which must be synchronized with the database? In other words, would any DML operations be executed if we flushed this session?- Specified by:
isDirtyin interfaceSession- Returns:
- True if the session contains pending changes; false otherwise.
- Throws:
HibernateException- could not perform dirtying checking
-
isDefaultReadOnly
public boolean isDefaultReadOnly()
Description copied from interface:SessionWill entities and proxies that are loaded into this session be made read-only by default? To determine the read-only/modifiable setting for a particular entity or proxy:- 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 is already in this session:- 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:
To override this session's read-only/modifiable setting for entities and proxies loaded by a Query:,Query.setReadOnly(boolean)
-
getIdentifier
public java.io.Serializable getIdentifier(java.lang.Object object)
Description copied from interface:SessionReturn the identifier value of the given entity as 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- Returns:
- the identifier
-
contains
public boolean contains(java.lang.String entityName, java.lang.Object object)Description copied from interface:SessionCheck if this entity is associated with this Session. This form caters to non-POJO entities, by allowing the entity-name to be passed in
-
evict
public void evict(java.lang.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 with cascade="evict".
-
load
public <T> T load(java.lang.Class<T> theClass, java.io.Serializable id, LockMode lockMode)Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists. Convenient form ofSession.load(Class, Serializable, 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, Serializable, LockOptions)
-
load
public <T> T load(java.lang.Class<T> theClass, java.io.Serializable id, LockOptions lockOptions)Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
-
load
public java.lang.Object load(java.lang.String entityName, java.io.Serializable id, LockMode lockMode)Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists. Convenient form ofSession.load(String, Serializable, LockOptions)- Specified by:
loadin interfaceSession- Parameters:
entityName- a persistent classid- a valid identifier of an existing persistent instance of the classlockMode- the lock level- Returns:
- the persistent instance or proxy
- See Also:
Session.load(String, Serializable, LockOptions)
-
load
public java.lang.Object load(java.lang.String entityName, java.io.Serializable id, LockOptions lockOptions)Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
-
load
public <T> T load(java.lang.Class<T> theClass, java.io.Serializable id)Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, assuming that the instance exists. 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 (use get() instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.
-
load
public java.lang.Object load(java.lang.String entityName, java.io.Serializable id)Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, assuming that the instance exists. 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 (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(java.lang.Object object, java.io.Serializable id)Description copied from interface:SessionRead the persistent state associated with the given identifier into the given transient instance.
-
replicate
public void replicate(java.lang.Object object, ReplicationMode replicationMode)Description copied from interface:SessionPersist the state of the given detached instance, reusing the current identifier value. This operation cascades to associated instances if the association is mapped withcascade="replicate"
-
replicate
public void replicate(java.lang.String entityName, java.lang.Object object, ReplicationMode replicationMode)Description copied from interface:SessionPersist the state of the given detached instance, reusing the current identifier value. This operation cascades to associated instances if the association is mapped withcascade="replicate"
-
save
public java.io.Serializable save(java.lang.Object object)
Description copied from interface:SessionPersist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if the assigned generator is used.) This operation cascades to associated instances if the association is mapped withcascade="save-update"
-
save
public java.io.Serializable save(java.lang.String entityName, java.lang.Object object)Description copied from interface:SessionPersist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if the assigned generator is used.) This operation cascades to associated instances if the association is mapped withcascade="save-update"
-
saveOrUpdate
public void saveOrUpdate(java.lang.Object object)
Description copied from interface:SessionEitherSession.save(Object)orSession.update(Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking). This operation cascades to associated instances if the association is mapped withcascade="save-update"- Specified by:
saveOrUpdatein interfaceSession- Parameters:
object- a transient or detached instance containing new or updated state- See Also:
Session.save(java.lang.Object),Session.update(Object object)
-
saveOrUpdate
public void saveOrUpdate(java.lang.String entityName, java.lang.Object object)Description copied from interface:SessionEitherSession.save(String, Object)orSession.update(String, Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking). This operation cascades to associated instances if the association is mapped withcascade="save-update"- Specified by:
saveOrUpdatein interfaceSession- Parameters:
entityName- The entity nameobject- a transient or detached instance containing new or updated state- See Also:
Session.save(String,Object),Session.update(String,Object)
-
update
public void update(java.lang.Object object)
Description copied from interface:SessionUpdate the persistent instance with the identifier of the given detached instance. If there is a persistent instance with the same identifier, an exception is thrown. This operation cascades to associated instances if the association is mapped withcascade="save-update"
-
update
public void update(java.lang.String entityName, java.lang.Object object)Description copied from interface:SessionUpdate the persistent instance with the identifier of the given detached instance. If there is a persistent instance with the same identifier, an exception is thrown. This operation cascades to associated instances if the association is mapped withcascade="save-update"
-
merge
public java.lang.Object merge(java.lang.Object 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 of 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 withcascade="merge"The semantics of this method are defined by JSR-220.- 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 java.lang.Object merge(java.lang.String entityName, java.lang.Object 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 of 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 withcascade="merge"The semantics of this method are defined by JSR-220.
-
persist
public void persist(java.lang.Object object)
Description copied from interface:SessionMake a transient instance persistent. This operation cascades to associated instances if the association is mapped withcascade="persist"The semantics of this method are defined by JSR-220.- Specified by:
persistin interfaceEntityManager- Specified by:
persistin interfaceSession- Parameters:
object- a transient instance to be made persistent
-
persist
public void persist(java.lang.String entityName, java.lang.Object object)Description copied from interface:SessionMake a transient instance persistent. This operation cascades to associated instances if the association is mapped withcascade="persist"The semantics of this method are defined by JSR-220.
-
delete
public void delete(java.lang.Object object)
Description copied from interface:SessionRemove a persistent instance from the datastore. The argument may be an instance associated with the receiving Session or a transient instance with an identifier associated with existing persistent state. This operation cascades to associated instances if the association is mapped withcascade="delete"
-
delete
public void delete(java.lang.String entityName, java.lang.Object object)Description copied from interface:SessionRemove a persistent instance from the datastore. The object argument may be an instance associated with the receiving Session or a transient instance with an identifier associated with existing persistent state. This operation cascades to associated instances if the association is mapped withcascade="delete"
-
lock
public void lock(java.lang.Object object, LockMode lockMode)Description copied from interface:SessionObtain the specified lock level upon the given object. This may be used to perform a version check (LockMode.READ), to upgrade to a pessimistic lock (LockMode.PESSIMISTIC_WRITE), or to simply reassociate a transient instance with a session (LockMode.NONE). This operation cascades to associated instances if the association is mapped with cascade="lock". Convenient form ofSession.LockRequest.lock(Object)viaSession.buildLockRequest(LockOptions)- Specified by:
lockin interfaceSession- Parameters:
object- a persistent or transient instancelockMode- the lock level- See Also:
Session.buildLockRequest(LockOptions),Session.LockRequest.lock(Object)
-
lock
public void lock(java.lang.String entityName, java.lang.Object object, LockMode lockMode)Description copied from interface:SessionObtain the specified lock level upon the given object. This may be used to perform a version check (LockMode.OPTIMISTIC), to upgrade to a pessimistic lock (LockMode.PESSIMISTIC_WRITE), or to simply reassociate a transient instance with a session (LockMode.NONE). This operation cascades to associated instances if the association is mapped with cascade="lock". Convenient form ofSession.LockRequest.lock(String, Object)viaSession.buildLockRequest(LockOptions)- Specified by:
lockin interfaceSession- Parameters:
entityName- The name of the entityobject- a persistent or transient instancelockMode- the lock level- See Also:
Session.buildLockRequest(LockOptions),Session.LockRequest.lock(String, Object)
-
buildLockRequest
public Session.LockRequest buildLockRequest(LockOptions lockOptions)
Description copied from interface:SessionBuild a LockRequest that specifies the LockMode, pessimistic lock timeout and lock scope. timeout and scope is ignored for optimistic locking. After building the LockRequest, call LockRequest.lock to perform the requested locking. Example usage:session.buildLockRequest().setLockMode(LockMode.PESSIMISTIC_WRITE).setTimeOut(60000).lock(entity);- Specified by:
buildLockRequestin interfaceSession- Parameters:
lockOptions- contains the lock level- Returns:
- a lockRequest that can be used to lock the passed object.
-
refresh
public void refresh(java.lang.Object object)
Description copied from interface:SessionRe-read the state of the given instance from the underlying database. It is inadvisable to use this to implement long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances. For example- where a database trigger alters the object state upon insert or update
- after executing direct SQL (eg. a mass update) in the same session
- after inserting a Blob or Clob
- Specified by:
refreshin interfaceEntityManager- Specified by:
refreshin interfaceSession- Parameters:
object- a persistent or detached instance
-
refresh
public void refresh(java.lang.String entityName, java.lang.Object object)Description copied from interface:SessionRe-read the state of the given instance from the underlying database. It is inadvisable to use this to implement long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances. For example- where a database trigger alters the object state upon insert or update
- after executing direct SQL (eg. a mass update) in the same session
- after inserting a Blob or Clob
-
refresh
public void refresh(java.lang.Object object, LockMode lockMode)Description copied from interface:SessionRe-read the state of the given instance from the underlying database, with the given LockMode. It is inadvisable to use this to implement long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances. Convenient form ofSession.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(java.lang.Object object, LockOptions lockOptions)Description copied from interface:SessionRe-read the state of the given instance from the underlying database, with the given LockMode. It is inadvisable to use this to implement long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances.
-
refresh
public void refresh(java.lang.String entityName, java.lang.Object object, LockOptions lockOptions)Description copied from interface:SessionRe-read the state of the given instance from the underlying database, with the given LockMode. It is inadvisable to use this to implement long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances.
-
getCurrentLockMode
public LockMode getCurrentLockMode(java.lang.Object object)
Description copied from interface:SessionDetermine the current lock mode of the given object.- Specified by:
getCurrentLockModein interfaceSession- Parameters:
object- a persistent instance- Returns:
- the current lock mode
-
createFilter
@Deprecated public Query createFilter(java.lang.Object collection, java.lang.String queryString)
Deprecated.Description copied from interface:SessionCreate aQueryinstance for the given collection and filter string. Contains an implicitFROMelement namedthiswhich refers to the defined table for the collection elements, as well as an implicitWHERErestriction for this particular collection instance's key value.- Specified by:
createFilterin interfaceSession- Parameters:
collection- a persistent collectionqueryString- a Hibernate query fragment.- Returns:
- The query instance for manipulation and execution
-
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 of ScrollableResults.- Specified by:
clearin interfaceEntityManager- Specified by:
clearin interfaceSession
-
get
public <T> T get(java.lang.Class<T> entityType, java.io.Serializable 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.)
-
get
public <T> T get(java.lang.Class<T> entityType, java.io.Serializable id, LockMode lockMode)Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.) Obtain the specified lock mode if the instance exists. Convenient form ofSession.get(Class, Serializable, LockOptions)- 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, Serializable, LockOptions)
-
get
public <T> T get(java.lang.Class<T> entityType, java.io.Serializable 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 java.lang.Object get(java.lang.String entityName, java.io.Serializable 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 java.lang.Object get(java.lang.String entityName, java.io.Serializable id, LockMode lockMode)Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.) Obtain the specified lock mode if the instance exists. Convenient form ofSession.get(String, Serializable, 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, Serializable, LockOptions)
-
get
public java.lang.Object get(java.lang.String entityName, java.io.Serializable 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 java.lang.String getEntityName(java.lang.Object object)
Description copied from interface:SessionReturn the entity name for a persistent entity.- Specified by:
getEntityNamein interfaceSession- Parameters:
object- a persistent entity- Returns:
- the entity name
-
getReference
public <T> T getReference(T object)
Description copied from interface:SessionReturn a reference to the persistent instance with the same identity as the given instance, which might be detached, making the assumption that the instance is still persistent in the database. This method never results in access to the underlying data store, and thus might return a proxy that is initialized on-demand, when a non-identifier method is accessed.- Specified by:
getReferencein interfaceSession- Parameters:
object- a detached persistent instance- Returns:
- the persistent instance or proxy
-
byId
public IdentifierLoadAccess byId(java.lang.String entityName)
Description copied from interface:SessionCreate anIdentifierLoadAccessinstance to retrieve the specified entity type by primary key.
-
byMultipleIds
public <T> MultiIdentifierLoadAccess<T> byMultipleIds(java.lang.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 MultiIdentifierLoadAccess byMultipleIds(java.lang.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(java.lang.Class<T> entityClass)
Description copied from interface:SessionCreate anIdentifierLoadAccessinstance to retrieve the specified entity by primary key.
-
byNaturalId
public NaturalIdLoadAccess byNaturalId(java.lang.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(java.lang.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 SimpleNaturalIdLoadAccess bySimpleNaturalId(java.lang.String entityName)
Description copied from interface:SessionCreate aSimpleNaturalIdLoadAccessinstance to retrieve the specified entity by its natural 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(java.lang.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
-
enableFilter
public Filter enableFilter(java.lang.String filterName)
Description copied from interface:SessionEnable the named filter for this current session.- Specified by:
enableFilterin interfaceSession- Parameters:
filterName- The name of the filter to be enabled.- Returns:
- The Filter instance representing the enabled filter.
-
getEnabledFilter
public Filter getEnabledFilter(java.lang.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 Filter instance representing the enabled filter.
-
disableFilter
public void disableFilter(java.lang.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(java.lang.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:- Specified by:
isReadOnlyin interfaceSession- Parameters:
entityOrProxy- an entity or HibernateProxy- Returns:
trueif the entity or proxy is read-only,falseif the entity or proxy is modifiable.- See Also:
Session.isDefaultReadOnly()
-
setReadOnly
public void setReadOnly(java.lang.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 entities and proxies that are loaded into the session:- Specified by:
setReadOnlyin interfaceSession- Parameters:
entityOrProxy- an entity or HibernateProxyreadOnly-trueif the entity or proxy should be made read-only;falseif the entity or proxy should be made modifiable- See Also:
To override this session's read-only/modifiable setting for entities and proxies loaded by a Query:,Query.setReadOnly(boolean)
-
createEntityGraph
public <T> RootGraph<T> createEntityGraph(java.lang.Class<T> rootType)
- Specified by:
createEntityGraphin interfaceEntityManager- Specified by:
createEntityGraphin interfaceSession
-
createEntityGraph
public RootGraph<?> createEntityGraph(java.lang.String graphName)
- Specified by:
createEntityGraphin interfaceEntityManager- Specified by:
createEntityGraphin interfaceSession
-
getEntityGraph
public RootGraph<?> getEntityGraph(java.lang.String graphName)
- Specified by:
getEntityGraphin interfaceEntityManager- Specified by:
getEntityGraphin interfaceSession
-
getEntityGraphs
public <T> java.util.List<EntityGraph<? super T>> getEntityGraphs(java.lang.Class<T> entityClass)
- Specified by:
getEntityGraphsin interfaceEntityManager- Specified by:
getEntityGraphsin interfaceSession
-
disconnect
public java.sql.Connection disconnect()
Description copied from interface:SessionDisconnect the session from its underlying JDBC connection. This is intended for use in cases where the application has supplied the JDBC connection to the session and which require long-sessions (aka, conversations). It is considered an error to call this method on a session which was not opened by supplying the JDBC connection and an exception will be thrown. For non-user-supplied scenarios, normal transaction management already handles disconnection and reconnection automatically.- Specified by:
disconnectin interfaceSession- Returns:
- the application-supplied connection or
null - See Also:
Session.reconnect(Connection)
-
reconnect
public void reconnect(java.sql.Connection connection)
Description copied from interface:SessionReconnect to the given JDBC connection.- Specified by:
reconnectin interfaceSession- Parameters:
connection- a JDBC connection- See Also:
Session.disconnect()
-
isFetchProfileEnabled
public boolean isFetchProfileEnabled(java.lang.String name) throws UnknownProfileExceptionDescription copied from interface:SessionIs a particular fetch profile enabled on this session?- Specified by:
isFetchProfileEnabledin interfaceSession- Parameters:
name- The name of the profile to be checked.- Returns:
- True if fetch profile is enabled; false if not.
- Throws:
UnknownProfileException- Indicates that the given name does not match any known profile names- See Also:
for discussion of this feature
-
enableFetchProfile
public void enableFetchProfile(java.lang.String name) throws UnknownProfileExceptionDescription copied from interface:SessionEnable a particular fetch profile on this session. No-op if requested profile is already enabled.- Specified by:
enableFetchProfilein interfaceSession- Parameters:
name- The name of the fetch profile to be enabled.- Throws:
UnknownProfileException- Indicates that the given name does not match any known profile names- See Also:
for discussion of this feature
-
disableFetchProfile
public void disableFetchProfile(java.lang.String name) throws UnknownProfileExceptionDescription copied from interface:SessionDisable a particular fetch profile on this session. No-op if requested profile is already disabled.- Specified by:
disableFetchProfilein interfaceSession- Parameters:
name- The name of the fetch profile to be disabled.- Throws:
UnknownProfileException- Indicates that the given name does not match any known profile names- See Also:
for discussion of this feature
-
getTypeHelper
public TypeHelper getTypeHelper()
Description copied from interface:SessionConvenience access to theTypeHelperassociated with this session'sSessionFactory. Equivalent to callingSession.getSessionFactory().getTypeHelper()- Specified by:
getTypeHelperin interfaceSession- Returns:
- The
TypeHelperassociated with this session'sSessionFactory
-
getLobHelper
public LobHelper getLobHelper()
Description copied from interface:SessionRetrieve this session's helper/delegate for creating LOB instances.- Specified by:
getLobHelperin interfaceSession- Returns:
- This session's LOB helper
-
addEventListeners
public void addEventListeners(SessionEventListener... listeners)
Description copied from interface:SessionAdd one or more listeners to the Session- Specified by:
addEventListenersin interfaceSession- Parameters:
listeners- The listener(s) to add
-
createQuery
public <T> Query<T> createQuery(java.lang.String queryString, java.lang.Class<T> resultType)
Description copied from interface:QueryProducerCreate a typedQueryinstance for the given HQL/JPQL query string.- Specified by:
createQueryin interfaceEntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceSession- Parameters:
queryString- The HQL/JPQL queryresultType- The type of the query result- Returns:
- The Query instance for manipulation and execution
- See Also:
EntityManager.createQuery(String,Class)
-
createQuery
public <T> Query<T> createQuery(CriteriaQuery<T> criteriaQuery)
- Specified by:
createQueryin interfaceEntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceSession
-
createQuery
public Query createQuery(CriteriaUpdate updateQuery)
- Specified by:
createQueryin interfaceEntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceSession
-
createQuery
public Query createQuery(CriteriaDelete deleteQuery)
- Specified by:
createQueryin interfaceEntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceSession
-
createNamedQuery
public <T> Query<T> createNamedQuery(java.lang.String name, java.lang.Class<T> resultType)
Description copied from interface:QueryProducerThe JPA-defined named, typed query creation method. This form can only represent an HQL/JPQL query (not a native query).- Specified by:
createNamedQueryin interfaceEntityManager- Specified by:
createNamedQueryin interfaceQueryProducer- Specified by:
createNamedQueryin interfaceSession- Parameters:
name- the name of a query defined in metadataresultType- the type of the query result- Returns:
- The Query instance for manipulation and execution
- See Also:
EntityManager.createNamedQuery(String,Class)
-
createSQLQuery
public NativeQuery createSQLQuery(java.lang.String queryString)
Description copied from interface:SessionCreate aNativeQueryinstance for the given SQL query string.- Specified by:
createSQLQueryin interfaceQueryProducer- Specified by:
createSQLQueryin interfaceSession- Parameters:
queryString- The SQL query- Returns:
- The query instance for manipulation and execution
-
getTenantIdentifier
public java.lang.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 interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- 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 Transaction instance
- See Also:
SharedSessionContract.getTransaction()
-
getTransaction
public Transaction getTransaction()
Description copied from interface:SharedSessionContractGet theTransactioninstance associated with this session. The concrete type of the returnedTransactionobject is determined by thehibernate.transaction_factoryproperty.- Specified by:
getTransactionin interfaceEntityManager- Specified by:
getTransactionin interfaceSharedSessionContract- Returns:
- a Transaction instance
-
createQuery
public Query createQuery(java.lang.String queryString)
Description copied from interface:QueryProducerCreate aQueryinstance for the given HQL/JPQL query string.- Specified by:
createQueryin interfaceEntityManager- Specified by:
createQueryin interfaceQueryProducer- Specified by:
createQueryin interfaceSharedSessionContract- Parameters:
queryString- The HQL/JPQL query- Returns:
- The Query instance for manipulation and execution
- See Also:
EntityManager.createQuery(String)
-
getNamedQuery
public Query getNamedQuery(java.lang.String queryName)
Description copied from interface:QueryProducerCreate aQueryinstance for the named query.- Specified by:
getNamedQueryin interfaceQueryProducer- Specified by:
getNamedQueryin interfaceSharedSessionContract- Parameters:
queryName- the name of a pre-defined, named query- Returns:
- The Query instance for manipulation and execution
-
getNamedProcedureCall
public ProcedureCall getNamedProcedureCall(java.lang.String name)
Description copied from interface:SharedSessionContractGets a ProcedureCall based 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(java.lang.String procedureName)
Description copied from interface:SharedSessionContractCreates a call to 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(java.lang.String procedureName, java.lang.Class... resultClasses)
Description copied from interface:SharedSessionContractCreates a call to a stored procedure with specific result set entity mappings. Each class named 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(java.lang.String procedureName, java.lang.String... resultSetMappings)
Description copied from interface:SharedSessionContractCreates a call to a stored procedure with specific 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.
-
createCriteria
@Deprecated public Criteria createCriteria(java.lang.Class persistentClass)
Deprecated.Description copied from interface:SharedSessionContractCreateCriteriainstance for the given class (entity or subclasses/implementors).- Specified by:
createCriteriain interfaceSharedSessionContract- Parameters:
persistentClass- The class, which is an entity, or has entity subclasses/implementors- Returns:
- The criteria instance for manipulation and execution
-
createCriteria
@Deprecated public Criteria createCriteria(java.lang.Class persistentClass, java.lang.String alias)
Deprecated.Description copied from interface:SharedSessionContractCreateCriteriainstance for the given class (entity or subclasses/implementors), using a specific alias.- Specified by:
createCriteriain interfaceSharedSessionContract- Parameters:
persistentClass- The class, which is an entity, or has entity subclasses/implementorsalias- The alias to use- Returns:
- The criteria instance for manipulation and execution
-
createCriteria
@Deprecated public Criteria createCriteria(java.lang.String entityName)
Deprecated.Description copied from interface:SharedSessionContractCreateCriteriainstance for the given entity name.- Specified by:
createCriteriain interfaceSharedSessionContract- Parameters:
entityName- The entity name- Returns:
- The criteria instance for manipulation and execution
-
createCriteria
@Deprecated public Criteria createCriteria(java.lang.String entityName, java.lang.String alias)
Deprecated.Description copied from interface:SharedSessionContractCreateCriteriainstance for the given entity name, using a specific alias.- Specified by:
createCriteriain interfaceSharedSessionContract- Parameters:
entityName- The entity namealias- The alias to use- Returns:
- The criteria instance for manipulation and execution
-
getJdbcBatchSize
public java.lang.Integer getJdbcBatchSize()
Description copied from interface:SharedSessionContractGet the Session-level JDBC batch size for the current Session. Overrides the SessionFactory JDBC batch size defined by thehibernate.default_batch_fetch_sizeconfiguration property for the scope of the currentSession.- Specified by:
getJdbcBatchSizein interfaceSharedSessionContract- Returns:
- Session-level JDBC batch size
- See Also:
SessionFactoryOptions.getJdbcBatchSize(),SessionFactoryBuilder.applyJdbcBatchSize(int)
-
setJdbcBatchSize
public void setJdbcBatchSize(java.lang.Integer jdbcBatchSize)
Description copied from interface:SharedSessionContractSet the Session-level JDBC batch size. Overrides the SessionFactory JDBC batch size defined by thehibernate.default_batch_fetch_sizeconfiguration property for the scope of the currentSession.- Specified by:
setJdbcBatchSizein interfaceSharedSessionContract- Parameters:
jdbcBatchSize- Session-level JDBC batch size- See Also:
SessionFactoryOptions.getJdbcBatchSize(),SessionFactoryBuilder.applyJdbcBatchSize(int)
-
doWork
public void doWork(Work work) throws HibernateException
Description copied from interface:SharedSessionContractController for allowing users to perform JDBC related work using the Connection managed 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:SharedSessionContractController for allowing users to perform JDBC related work using the Connection managed by this Session. After execution returns the result of theReturningWork.execute(java.sql.Connection)call.- 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 from calling
ReturningWork.execute(java.sql.Connection). - Throws:
HibernateException- Generally indicates wrappedSQLException
-
createNamedQuery
public Query createNamedQuery(java.lang.String name)
Description copied from interface:QueryProducerThe JPA-defined named query creation method. This form can represent an HQL/JPQL query or a native query.- Specified by:
createNamedQueryin interfaceEntityManager- Specified by:
createNamedQueryin interfaceQueryProducer- Parameters:
name- the name of a pre-defined, named query- Returns:
- The Query instance for manipulation and execution
- See Also:
EntityManager.createNamedQuery(String)
-
createNativeQuery
public NativeQuery createNativeQuery(java.lang.String sqlString)
Description copied from interface:QueryProducerCreate a NativeQuery instance for the given native (SQL) query- Specified by:
createNativeQueryin interfaceEntityManager- Specified by:
createNativeQueryin interfaceQueryProducer- Parameters:
sqlString- a native SQL query string- Returns:
- The NativeQuery instance for manipulation and execution
- See Also:
EntityManager.createNativeQuery(String)
-
createNativeQuery
public NativeQuery createNativeQuery(java.lang.String sqlString, java.lang.String resultSetMapping)
Description copied from interface:QueryProducerCreate a NativeQuery instance for the given native (SQL) query using implicit mapping to the specified Java type.- Specified by:
createNativeQueryin interfaceEntityManager- Specified by:
createNativeQueryin interfaceQueryProducer- Parameters:
sqlString- Native (SQL) query stringresultSetMapping- The explicit (named) result mapping- Returns:
- The NativeQuery instance for manipulation and execution
- See Also:
EntityManager.createNativeQuery(String,Class),SqlResultSetMapping
-
getNamedSQLQuery
@Deprecated public Query getNamedSQLQuery(java.lang.String name)
Deprecated.Description copied from interface:QueryProducerGet a NativeQuery instance for a named native SQL query- Specified by:
getNamedSQLQueryin interfaceQueryProducer- Parameters:
name- The name of the pre-defined query- Returns:
- The NativeQuery instance for manipulation and execution
-
getNamedNativeQuery
public NativeQuery getNamedNativeQuery(java.lang.String name)
Description copied from interface:QueryProducerGet a NativeQuery instance for a named native SQL query- Specified by:
getNamedNativeQueryin interfaceQueryProducer- Parameters:
name- The name of the pre-defined query- Returns:
- The NativeQuery instance for manipulation and execution
-
remove
public void remove(java.lang.Object entity)
- Specified by:
removein interfaceEntityManager
-
find
public <T> T find(java.lang.Class<T> entityClass, java.lang.Object primaryKey)- Specified by:
findin interfaceEntityManager
-
find
public <T> T find(java.lang.Class<T> entityClass, java.lang.Object primaryKey, java.util.Map<java.lang.String,java.lang.Object> properties)- Specified by:
findin interfaceEntityManager
-
find
public <T> T find(java.lang.Class<T> entityClass, java.lang.Object primaryKey, LockModeType lockMode)- Specified by:
findin interfaceEntityManager
-
find
public <T> T find(java.lang.Class<T> entityClass, java.lang.Object primaryKey, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)- Specified by:
findin interfaceEntityManager
-
getReference
public <T> T getReference(java.lang.Class<T> entityClass, java.lang.Object primaryKey)- Specified by:
getReferencein interfaceEntityManager
-
setFlushMode
public void setFlushMode(FlushModeType flushMode)
- Specified by:
setFlushModein interfaceEntityManager
-
lock
public void lock(java.lang.Object entity, LockModeType lockMode)- Specified by:
lockin interfaceEntityManager
-
lock
public void lock(java.lang.Object entity, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)- Specified by:
lockin interfaceEntityManager
-
refresh
public void refresh(java.lang.Object entity, java.util.Map<java.lang.String,java.lang.Object> properties)- Specified by:
refreshin interfaceEntityManager
-
refresh
public void refresh(java.lang.Object entity, LockModeType lockMode)- Specified by:
refreshin interfaceEntityManager
-
refresh
public void refresh(java.lang.Object entity, LockModeType lockMode, java.util.Map<java.lang.String,java.lang.Object> properties)- Specified by:
refreshin interfaceEntityManager
-
detach
public void detach(java.lang.Object entity)
- Specified by:
detachin interfaceEntityManager
-
contains
public boolean contains(java.lang.Object entity)
- Specified by:
containsin interfaceEntityManager
-
getLockMode
public LockModeType getLockMode(java.lang.Object entity)
- Specified by:
getLockModein interfaceEntityManager
-
setProperty
public void setProperty(java.lang.String propertyName, java.lang.Object value)- Specified by:
setPropertyin interfaceEntityManager
-
getProperties
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
- Specified by:
getPropertiesin interfaceEntityManager
-
createNativeQuery
public NativeQuery createNativeQuery(java.lang.String sqlString, java.lang.Class resultClass)
Description copied from interface:QueryProducerCreate a NativeQuery instance for the given native (SQL) query using implicit mapping to the specified Java type.- Specified by:
createNativeQueryin interfaceEntityManager- Specified by:
createNativeQueryin interfaceQueryProducer- Parameters:
sqlString- 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)
-
createNamedStoredProcedureQuery
public StoredProcedureQuery createNamedStoredProcedureQuery(java.lang.String name)
- Specified by:
createNamedStoredProcedureQueryin interfaceEntityManager
-
createStoredProcedureQuery
public StoredProcedureQuery createStoredProcedureQuery(java.lang.String procedureName)
- Specified by:
createStoredProcedureQueryin interfaceEntityManager
-
createStoredProcedureQuery
public StoredProcedureQuery createStoredProcedureQuery(java.lang.String procedureName, java.lang.Class... resultClasses)
- Specified by:
createStoredProcedureQueryin interfaceEntityManager
-
createStoredProcedureQuery
public StoredProcedureQuery createStoredProcedureQuery(java.lang.String procedureName, java.lang.String... resultSetMappings)
- Specified by:
createStoredProcedureQueryin interfaceEntityManager
-
joinTransaction
public void joinTransaction()
- Specified by:
joinTransactionin interfaceEntityManager
-
isJoinedToTransaction
public boolean isJoinedToTransaction()
- Specified by:
isJoinedToTransactionin interfaceEntityManager
-
unwrap
public <T> T unwrap(java.lang.Class<T> cls)
- Specified by:
unwrapin interfaceEntityManager
-
getDelegate
public java.lang.Object getDelegate()
- Specified by:
getDelegatein interfaceEntityManager
-
getEntityManagerFactory
public EntityManagerFactory getEntityManagerFactory()
- Specified by:
getEntityManagerFactoryin interfaceEntityManager
-
getCriteriaBuilder
public CriteriaBuilder getCriteriaBuilder()
- Specified by:
getCriteriaBuilderin interfaceEntityManager
-
getMetamodel
public Metamodel getMetamodel()
- Specified by:
getMetamodelin interfaceEntityManager
-
getSession
public Session getSession()
Description copied from interface:HibernateEntityManagerRetrieve a reference to the HibernateSessionused by thisEntityManager.- Specified by:
getSessionin interfaceHibernateEntityManager- Returns:
- The session
-
-