Package org.hibernate.engine.spi
Class SessionLazyDelegator
- java.lang.Object
-
- org.hibernate.engine.spi.SessionLazyDelegator
-
- All Implemented Interfaces:
Closeable
,Serializable
,AutoCloseable
,EntityManager
,HibernateEntityManager
,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 void
addEventListeners(SessionEventListener... listeners)
Add one or more listeners to the SessionTransaction
beginTransaction()
Begin a unit of work and return the associatedTransaction
object.Session.LockRequest
buildLockRequest(LockOptions lockOptions)
Build a LockRequest that specifies the LockMode, pessimistic lock timeout and lock scope.<T> IdentifierLoadAccess<T>
byId(Class<T> entityClass)
Create anIdentifierLoadAccess
instance to retrieve the specified entity by primary key.IdentifierLoadAccess
byId(String entityName)
Create anIdentifierLoadAccess
instance to retrieve the specified entity type by primary key.<T> MultiIdentifierLoadAccess<T>
byMultipleIds(Class<T> entityClass)
Create aMultiIdentifierLoadAccess
instance to retrieve multiple entities at once as specified by primary key values.MultiIdentifierLoadAccess
byMultipleIds(String entityName)
Create aMultiIdentifierLoadAccess
instance to retrieve multiple entities at once as specified by primary key values.<T> NaturalIdLoadAccess<T>
byNaturalId(Class<T> entityClass)
Create aNaturalIdLoadAccess
instance to retrieve the specified entity by its natural id.NaturalIdLoadAccess
byNaturalId(String entityName)
Create aNaturalIdLoadAccess
instance to retrieve the specified entity by its natural id.<T> SimpleNaturalIdLoadAccess<T>
bySimpleNaturalId(Class<T> entityClass)
Create aSimpleNaturalIdLoadAccess
instance to retrieve the specified entity by its simple (single attribute) natural id.SimpleNaturalIdLoadAccess
bySimpleNaturalId(String entityName)
Create aSimpleNaturalIdLoadAccess
instance to retrieve the specified entity by its natural id.void
cancelQuery()
Cancel the execution of the current query.void
clear()
Completely clear the session.void
close()
End the session by releasing the JDBC connection and cleaning up.boolean
contains(Object entity)
boolean
contains(String entityName, Object object)
Check if this entity is associated with this Session.Criteria
createCriteria(Class persistentClass)
Deprecated.Criteria
createCriteria(Class persistentClass, String alias)
Deprecated.Criteria
createCriteria(String entityName)
Deprecated.Criteria
createCriteria(String entityName, String alias)
Deprecated.<T> RootGraph<T>
createEntityGraph(Class<T> rootType)
RootGraph<?>
createEntityGraph(String graphName)
Query
createFilter(Object collection, String queryString)
Deprecated.Query
createNamedQuery(String name)
The JPA-defined named query creation method.<T> Query<T>
createNamedQuery(String name, Class<T> resultType)
The JPA-defined named, typed query creation method.StoredProcedureQuery
createNamedStoredProcedureQuery(String name)
NativeQuery
createNativeQuery(String sqlString)
Create a NativeQuery instance for the given native (SQL) queryNativeQuery
createNativeQuery(String sqlString, Class resultClass)
Create a NativeQuery instance for the given native (SQL) query using implicit mapping to the specified Java type.NativeQuery
createNativeQuery(String sqlString, String resultSetMapping)
Create a NativeQuery instance for the given native (SQL) query using implicit mapping to the specified Java type.Query
createQuery(String queryString)
Create aQuery
instance for the given HQL/JPQL query string.<T> Query<T>
createQuery(String queryString, Class<T> resultType)
Create a typedQuery
instance for the given HQL/JPQL query string.Query
createQuery(CriteriaDelete deleteQuery)
<T> Query<T>
createQuery(CriteriaQuery<T> criteriaQuery)
Query
createQuery(CriteriaUpdate updateQuery)
NativeQuery
createSQLQuery(String queryString)
Create aNativeQuery
instance for the given SQL query string.ProcedureCall
createStoredProcedureCall(String procedureName)
Creates a call to a stored procedure.ProcedureCall
createStoredProcedureCall(String procedureName, Class... resultClasses)
Creates a call to a stored procedure with specific result set entity mappings.ProcedureCall
createStoredProcedureCall(String procedureName, String... resultSetMappings)
Creates a call to a stored procedure with specific result set entity mappings.StoredProcedureQuery
createStoredProcedureQuery(String procedureName)
StoredProcedureQuery
createStoredProcedureQuery(String procedureName, Class... resultClasses)
StoredProcedureQuery
createStoredProcedureQuery(String procedureName, String... resultSetMappings)
void
delete(Object object)
Remove a persistent instance from the datastore.void
delete(String entityName, Object object)
Remove a persistent instance from the datastore.void
detach(Object entity)
void
disableFetchProfile(String name)
Disable a particular fetch profile on this session.void
disableFilter(String filterName)
Disable the named filter for the current session.Connection
disconnect()
Disconnect the session from its underlying JDBC connection.<T> T
doReturningWork(ReturningWork<T> work)
Controller for allowing users to perform JDBC related work using the Connection managed by this Session.void
doWork(Work work)
Controller for allowing users to perform JDBC related work using the Connection managed by this Session.void
enableFetchProfile(String name)
Enable a particular fetch profile on this session.Filter
enableFilter(String filterName)
Enable the named filter for this current session.void
evict(Object object)
Remove this instance from the session cache.<T> T
find(Class<T> entityClass, Object primaryKey)
<T> T
find(Class<T> entityClass, Object primaryKey, Map<String,Object> properties)
<T> T
find(Class<T> entityClass, Object primaryKey, LockModeType lockMode)
<T> T
find(Class<T> entityClass, Object primaryKey, LockModeType lockMode, Map<String,Object> properties)
void
flush()
Force this session to flush.<T> T
get(Class<T> entityType, 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> T
get(Class<T> entityType, 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> T
get(Class<T> entityType, 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.Object
get(String entityName, Serializable id)
Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance.Object
get(String entityName, 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.Object
get(String entityName, 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.CacheMode
getCacheMode()
Get the current cache mode.CriteriaBuilder
getCriteriaBuilder()
LockMode
getCurrentLockMode(Object object)
Determine the current lock mode of the given object.Object
getDelegate()
Filter
getEnabledFilter(String filterName)
Retrieve a currently enabled filter by name.RootGraph<?>
getEntityGraph(String graphName)
<T> List<EntityGraph<? super T>>
getEntityGraphs(Class<T> entityClass)
EntityManagerFactory
getEntityManagerFactory()
String
getEntityName(Object object)
Return the entity name for a persistent entity.FlushModeType
getFlushMode()
FlushMode
getHibernateFlushMode()
Get the current flush mode for this session.Serializable
getIdentifier(Object object)
Return the identifier value of the given entity as associated with this session.Integer
getJdbcBatchSize()
Get the Session-level JDBC batch size for the current Session.LobHelper
getLobHelper()
Retrieve this session's helper/delegate for creating LOB instances.LockModeType
getLockMode(Object entity)
Metamodel
getMetamodel()
NativeQuery
getNamedNativeQuery(String name)
Get a NativeQuery instance for a named native SQL queryProcedureCall
getNamedProcedureCall(String name)
Gets a ProcedureCall based on a named templateQuery
getNamedQuery(String queryName)
Create aQuery
instance for the named query.Query
getNamedSQLQuery(String name)
Deprecated.Map<String,Object>
getProperties()
<T> T
getReference(Class<T> entityClass, Object primaryKey)
Session
getSession()
Retrieve a reference to the HibernateSession
used by thisEntityManager
.SessionFactory
getSessionFactory()
Get the session factory which created this session.SessionStatistics
getStatistics()
Get the statistics for this session.String
getTenantIdentifier()
Obtain the tenant identifier associated with this session.Transaction
getTransaction()
Get theTransaction
instance associated with this session.TypeHelper
getTypeHelper()
Convenience access to theTypeHelper
associated with this session'sSessionFactory
.boolean
isConnected()
Check if the session is currently connected.boolean
isDefaultReadOnly()
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:boolean
isDirty()
Does this session contain any changes which must be synchronized with the database? In other words, would any DML operations be executed if we flushed this session?boolean
isFetchProfileEnabled(String name)
Is a particular fetch profile enabled on this session?boolean
isJoinedToTransaction()
boolean
isOpen()
Check if the session is still open.boolean
isReadOnly(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:void
joinTransaction()
<T> T
load(Class<T> theClass, Serializable id)
Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.<T> T
load(Class<T> theClass, 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> T
load(Class<T> theClass, 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.void
load(Object object, Serializable id)
Read the persistent state associated with the given identifier into the given transient instance.Object
load(String entityName, Serializable id)
Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.Object
load(String entityName, 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.Object
load(String entityName, 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.void
lock(Object entity, LockModeType lockMode)
void
lock(Object entity, LockModeType lockMode, Map<String,Object> properties)
void
lock(Object object, LockMode lockMode)
Obtain the specified lock level upon the given object.void
lock(String entityName, Object object, LockMode lockMode)
Obtain the specified lock level upon the given object.Object
merge(Object object)
Copy the state of the given object onto the persistent object with the same identifier.Object
merge(String entityName, Object object)
Copy the state of the given object onto the persistent object with the same identifier.void
persist(Object object)
Make a transient instance persistent.void
persist(String entityName, Object object)
Make a transient instance persistent.void
reconnect(Connection connection)
Reconnect to the given JDBC connection.void
refresh(Object object)
Re-read the state of the given instance from the underlying database.void
refresh(Object entity, Map<String,Object> properties)
void
refresh(Object entity, LockModeType lockMode)
void
refresh(Object entity, LockModeType lockMode, Map<String,Object> properties)
void
refresh(Object object, LockMode lockMode)
Re-read the state of the given instance from the underlying database, with the given LockMode.void
refresh(Object object, LockOptions lockOptions)
Re-read the state of the given instance from the underlying database, with the given LockMode.void
refresh(String entityName, Object object)
Re-read the state of the given instance from the underlying database.void
refresh(String entityName, Object object, LockOptions lockOptions)
Re-read the state of the given instance from the underlying database, with the given LockMode.void
remove(Object entity)
void
replicate(Object object, ReplicationMode replicationMode)
Persist the state of the given detached instance, reusing the current identifier value.void
replicate(String entityName, Object object, ReplicationMode replicationMode)
Persist the state of the given detached instance, reusing the current identifier value.Serializable
save(Object object)
Persist the given transient instance, first assigning a generated identifier.Serializable
save(String entityName, Object object)
Persist the given transient instance, first assigning a generated identifier.void
saveOrUpdate(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).void
saveOrUpdate(String entityName, Object object)
EitherSession.save(String, Object)
orSession.update(String, Object)
the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking).SharedSessionBuilder
sessionWithOptions()
Obtain aSession
builder with the ability to grab certain information from this session.void
setCacheMode(CacheMode cacheMode)
Set the cache mode.void
setDefaultReadOnly(boolean readOnly)
Change the default for entities and proxies loaded into this session from modifiable to read-only mode, or from modifiable to read-only mode.void
setFlushMode(FlushModeType flushMode)
void
setFlushMode(FlushMode flushMode)
Deprecated.void
setHibernateFlushMode(FlushMode flushMode)
Set the flush mode for this session.void
setJdbcBatchSize(Integer jdbcBatchSize)
Set the Session-level JDBC batch size.void
setProperty(String propertyName, Object value)
void
setReadOnly(Object entityOrProxy, boolean readOnly)
Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode.<T> T
unwrap(Class<T> cls)
void
update(Object object)
Update the persistent instance with the identifier of the given detached instance.void
update(String entityName, Object object)
Update the persistent instance with the identifier of the given detached instance.
-
-
-
Method Detail
-
sessionWithOptions
public SharedSessionBuilder sessionWithOptions()
Description copied from interface:Session
Obtain aSession
builder with the ability to grab certain information from this session.- Specified by:
sessionWithOptions
in interfaceSession
- Returns:
- The session builder
-
flush
public void flush() throws HibernateException
Description copied from interface:Session
Force 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:
flush
in interfaceEntityManager
- Specified by:
flush
in 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:Session
Set 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.MANUAL
at the start of the session (in order to achieve some extra performance).- Specified by:
setFlushMode
in interfaceSession
- Parameters:
flushMode
- the new flush mode
-
getFlushMode
public FlushModeType getFlushMode()
Description copied from interface:Session
For 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 JPAFlushModeType
rather than Hibernate'sFlushMode
. For the former behavior, useSession.getHibernateFlushMode()
instead.- Specified by:
getFlushMode
in interfaceEntityManager
- Specified by:
getFlushMode
in interfaceSession
- Returns:
- The FlushModeType in effect for this Session.
-
setHibernateFlushMode
public void setHibernateFlushMode(FlushMode flushMode)
Description copied from interface:Session
Set 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.MANUAL
at the start of the session (in order to achieve some extra performance).- Specified by:
setHibernateFlushMode
in interfaceSession
- Parameters:
flushMode
- the new flush mode
-
getHibernateFlushMode
public FlushMode getHibernateFlushMode()
Description copied from interface:Session
Get the current flush mode for this session.- Specified by:
getHibernateFlushMode
in interfaceSession
- Returns:
- The flush mode
-
setCacheMode
public void setCacheMode(CacheMode cacheMode)
Description copied from interface:Session
Set the cache mode. Cache mode determines the manner in which this session can interact with the second level cache.- Specified by:
setCacheMode
in interfaceSession
- Parameters:
cacheMode
- The new cache mode.
-
getCacheMode
public CacheMode getCacheMode()
Description copied from interface:Session
Get the current cache mode.- Specified by:
getCacheMode
in interfaceSession
- Returns:
- The current cache mode.
-
getSessionFactory
public SessionFactory getSessionFactory()
Description copied from interface:Session
Get the session factory which created this session.- Specified by:
getSessionFactory
in interfaceSession
- Returns:
- The session factory.
- See Also:
SessionFactory
-
cancelQuery
public void cancelQuery() throws HibernateException
Description copied from interface:Session
Cancel the execution of the current query. This is the sole method on session which may be safely called from another thread.- Specified by:
cancelQuery
in interfaceSession
- Throws:
HibernateException
- There was a problem canceling the query
-
isDirty
public boolean isDirty() throws HibernateException
Description copied from interface:Session
Does this session contain any changes which must be synchronized with the database? In other words, would any DML operations be executed if we flushed this session?- Specified by:
isDirty
in interfaceSession
- Returns:
- True if the session contains pending changes; false otherwise.
- Throws:
HibernateException
- could not perform dirtying checking
-
isDefaultReadOnly
public boolean isDefaultReadOnly()
Description copied from interface:Session
Will entities and proxies that are loaded into this session be made read-only by default? To determine the read-only/modifiable setting for a particular entity or proxy:- Specified by:
isDefaultReadOnly
in 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:Session
Change the default for entities and proxies loaded into this session from modifiable to read-only mode, or from modifiable to read-only mode. Read-only entities are not dirty-checked and snapshots of persistent state are not maintained. Read-only entities can be modified, but changes are not persisted. When a proxy is initialized, the loaded entity will have the same read-only/modifiable setting as the uninitialized proxy has, regardless of the session's current setting. To change the read-only/modifiable setting for a particular entity or proxy that is already in this session:- Specified by:
setDefaultReadOnly
in interfaceSession
- Parameters:
readOnly
- true, the default for loaded entities/proxies is read-only; false, the default for loaded entities/proxies is modifiable- See Also:
To override this session's read-only/modifiable setting for entities and proxies loaded by a Query:
,Query.setReadOnly(boolean)
-
getIdentifier
public Serializable getIdentifier(Object object)
Description copied from interface:Session
Return 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:
getIdentifier
in interfaceSession
- Parameters:
object
- a persistent instance- Returns:
- the identifier
-
contains
public boolean contains(String entityName, Object object)
Description copied from interface:Session
Check 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(Object object)
Description copied from interface:Session
Remove this instance from the session cache. Changes to the instance will not be synchronized with the database. This operation cascades to associated instances if the association is mapped with cascade="evict".
-
load
public <T> T load(Class<T> theClass, Serializable id, LockMode lockMode)
Description copied from interface:Session
Return 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:
load
in 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(Class<T> theClass, Serializable id, LockOptions lockOptions)
Description copied from interface:Session
Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
-
load
public Object load(String entityName, Serializable id, LockMode lockMode)
Description copied from interface:Session
Return 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:
load
in 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 Object load(String entityName, Serializable id, LockOptions lockOptions)
Description copied from interface:Session
Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.
-
load
public <T> T load(Class<T> theClass, Serializable id)
Description copied from interface:Session
Return 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 Object load(String entityName, Serializable id)
Description copied from interface:Session
Return 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(Object object, Serializable id)
Description copied from interface:Session
Read the persistent state associated with the given identifier into the given transient instance.
-
replicate
public void replicate(Object object, ReplicationMode replicationMode)
Description copied from interface:Session
Persist the state of the given detached instance, reusing the current identifier value. This operation cascades to associated instances if the association is mapped withcascade="replicate"
-
replicate
public void replicate(String entityName, Object object, ReplicationMode replicationMode)
Description copied from interface:Session
Persist the state of the given detached instance, reusing the current identifier value. This operation cascades to associated instances if the association is mapped withcascade="replicate"
-
save
public Serializable save(Object object)
Description copied from interface:Session
Persist 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 Serializable save(String entityName, Object object)
Description copied from interface:Session
Persist 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(Object object)
Description copied from interface:Session
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). This operation cascades to associated instances if the association is mapped withcascade="save-update"
- Specified by:
saveOrUpdate
in 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(String entityName, Object object)
Description copied from interface:Session
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). This operation cascades to associated instances if the association is mapped withcascade="save-update"
- Specified by:
saveOrUpdate
in interfaceSession
- Parameters:
entityName
- The entity nameobject
- a transient or detached instance containing new or updated state- See Also:
Session.save(String,Object)
,Session.update(String,Object)
-
update
public void update(Object object)
Description copied from interface:Session
Update 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(String entityName, Object object)
Description copied from interface:Session
Update 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 Object merge(Object object)
Description copied from interface:Session
Copy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved, save a copy 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:
merge
in interfaceEntityManager
- Specified by:
merge
in interfaceSession
- Parameters:
object
- a detached instance with state to be copied- Returns:
- an updated persistent instance
-
merge
public Object merge(String entityName, Object object)
Description copied from interface:Session
Copy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved, save a copy 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(Object object)
Description copied from interface:Session
Make 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:
persist
in interfaceEntityManager
- Specified by:
persist
in interfaceSession
- Parameters:
object
- a transient instance to be made persistent
-
persist
public void persist(String entityName, Object object)
Description copied from interface:Session
Make 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(Object object)
Description copied from interface:Session
Remove 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(String entityName, Object object)
Description copied from interface:Session
Remove 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(Object object, LockMode lockMode)
Description copied from interface:Session
Obtain 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:
lock
in interfaceSession
- Parameters:
object
- a persistent or transient instancelockMode
- the lock level- See Also:
Session.buildLockRequest(LockOptions)
,Session.LockRequest.lock(Object)
-
lock
public void lock(String entityName, Object object, LockMode lockMode)
Description copied from interface:Session
Obtain 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:
lock
in 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:Session
Build 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:
buildLockRequest
in interfaceSession
- Parameters:
lockOptions
- contains the lock level- Returns:
- a lockRequest that can be used to lock the passed object.
-
refresh
public void refresh(Object object)
Description copied from interface:Session
Re-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:
refresh
in interfaceEntityManager
- Specified by:
refresh
in interfaceSession
- Parameters:
object
- a persistent or detached instance
-
refresh
public void refresh(String entityName, Object object)
Description copied from interface:Session
Re-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(Object object, LockMode lockMode)
Description copied from interface:Session
Re-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:
refresh
in 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:Session
Re-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(String entityName, Object object, LockOptions lockOptions)
Description copied from interface:Session
Re-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(Object object)
Description copied from interface:Session
Determine the current lock mode of the given object.- Specified by:
getCurrentLockMode
in interfaceSession
- Parameters:
object
- a persistent instance- Returns:
- the current lock mode
-
createFilter
@Deprecated public Query createFilter(Object collection, String queryString)
Deprecated.Description copied from interface:Session
Create aQuery
instance for the given collection and filter string. Contains an implicitFROM
element namedthis
which refers to the defined table for the collection elements, as well as an implicitWHERE
restriction for this particular collection instance's key value.- Specified by:
createFilter
in 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:Session
Completely 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:
clear
in interfaceEntityManager
- Specified by:
clear
in interfaceSession
-
get
public <T> T get(Class<T> entityType, Serializable id)
Description copied from interface:Session
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.)
-
get
public <T> T get(Class<T> entityType, Serializable id, LockMode lockMode)
Description copied from interface:Session
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.) Obtain the specified lock mode if the instance exists. Convenient form ofSession.get(Class, Serializable, LockOptions)
- Specified by:
get
in 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(Class<T> entityType, Serializable id, LockOptions lockOptions)
Description copied from interface:Session
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.) Obtain the specified lock mode if the instance exists.
-
get
public Object get(String entityName, Serializable id)
Description copied from interface:Session
Return the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.)
-
get
public Object get(String entityName, Serializable id, LockMode lockMode)
Description copied from interface:Session
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.) Obtain the specified lock mode if the instance exists. Convenient form ofSession.get(String, Serializable, LockOptions)
- Specified by:
get
in 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 Object get(String entityName, Serializable id, LockOptions lockOptions)
Description copied from interface:Session
Return the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.) Obtain the specified lock mode if the instance exists.
-
getEntityName
public String getEntityName(Object object)
Description copied from interface:Session
Return the entity name for a persistent entity.- Specified by:
getEntityName
in interfaceSession
- Parameters:
object
- a persistent entity- Returns:
- the entity name
-
byId
public IdentifierLoadAccess byId(String entityName)
Description copied from interface:Session
Create anIdentifierLoadAccess
instance to retrieve the specified entity type by primary key.
-
byMultipleIds
public <T> MultiIdentifierLoadAccess<T> byMultipleIds(Class<T> entityClass)
Description copied from interface:Session
Create aMultiIdentifierLoadAccess
instance to retrieve multiple entities at once as specified by primary key values.- Specified by:
byMultipleIds
in 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(String entityName)
Description copied from interface:Session
Create aMultiIdentifierLoadAccess
instance to retrieve multiple entities at once as specified by primary key values.- Specified by:
byMultipleIds
in 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:Session
Create anIdentifierLoadAccess
instance to retrieve the specified entity by primary key.
-
byNaturalId
public NaturalIdLoadAccess byNaturalId(String entityName)
Description copied from interface:Session
Create aNaturalIdLoadAccess
instance to retrieve the specified entity by its natural id.- Specified by:
byNaturalId
in 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:Session
Create aNaturalIdLoadAccess
instance to retrieve the specified entity by its natural id.- Specified by:
byNaturalId
in 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(String entityName)
Description copied from interface:Session
Create aSimpleNaturalIdLoadAccess
instance to retrieve the specified entity by its natural id.- Specified by:
bySimpleNaturalId
in 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:Session
Create aSimpleNaturalIdLoadAccess
instance to retrieve the specified entity by its simple (single attribute) natural id.- Specified by:
bySimpleNaturalId
in 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(String filterName)
Description copied from interface:Session
Enable the named filter for this current session.- Specified by:
enableFilter
in interfaceSession
- Parameters:
filterName
- The name of the filter to be enabled.- Returns:
- The Filter instance representing the enabled filter.
-
getEnabledFilter
public Filter getEnabledFilter(String filterName)
Description copied from interface:Session
Retrieve a currently enabled filter by name.- Specified by:
getEnabledFilter
in interfaceSession
- Parameters:
filterName
- The name of the filter to be retrieved.- Returns:
- The Filter instance representing the enabled filter.
-
disableFilter
public void disableFilter(String filterName)
Description copied from interface:Session
Disable the named filter for the current session.- Specified by:
disableFilter
in interfaceSession
- Parameters:
filterName
- The name of the filter to be disabled.
-
getStatistics
public SessionStatistics getStatistics()
Description copied from interface:Session
Get the statistics for this session.- Specified by:
getStatistics
in interfaceSession
- Returns:
- The session statistics being collected for this session
-
isReadOnly
public boolean isReadOnly(Object entityOrProxy)
Description copied from interface:Session
Is the specified entity or proxy read-only? To get the default read-only/modifiable setting used for entities and proxies that are loaded into the session:- Specified by:
isReadOnly
in interfaceSession
- Parameters:
entityOrProxy
- an entity or HibernateProxy- Returns:
true
if the entity or proxy is read-only,false
if the entity or proxy is modifiable.- See Also:
Session.isDefaultReadOnly()
-
setReadOnly
public void setReadOnly(Object entityOrProxy, boolean readOnly)
Description copied from interface:Session
Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode. In read-only mode, no snapshot is maintained, the instance is never dirty checked, and changes are not persisted. If the entity or proxy already has the specified read-only/modifiable setting, then this method does nothing. To set the default read-only/modifiable setting used for entities and proxies that are loaded into the session:- Specified by:
setReadOnly
in interfaceSession
- Parameters:
entityOrProxy
- an entity or HibernateProxyreadOnly
-true
if the entity or proxy should be made read-only;false
if 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(Class<T> rootType)
- Specified by:
createEntityGraph
in interfaceEntityManager
- Specified by:
createEntityGraph
in interfaceSession
-
createEntityGraph
public RootGraph<?> createEntityGraph(String graphName)
- Specified by:
createEntityGraph
in interfaceEntityManager
- Specified by:
createEntityGraph
in interfaceSession
-
getEntityGraph
public RootGraph<?> getEntityGraph(String graphName)
- Specified by:
getEntityGraph
in interfaceEntityManager
- Specified by:
getEntityGraph
in interfaceSession
-
getEntityGraphs
public <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass)
- Specified by:
getEntityGraphs
in interfaceEntityManager
- Specified by:
getEntityGraphs
in interfaceSession
-
disconnect
public Connection disconnect()
Description copied from interface:Session
Disconnect 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:
disconnect
in interfaceSession
- Returns:
- the application-supplied connection or
null
- See Also:
Session.reconnect(Connection)
-
reconnect
public void reconnect(Connection connection)
Description copied from interface:Session
Reconnect to the given JDBC connection.- Specified by:
reconnect
in interfaceSession
- Parameters:
connection
- a JDBC connection- See Also:
Session.disconnect()
-
isFetchProfileEnabled
public boolean isFetchProfileEnabled(String name) throws UnknownProfileException
Description copied from interface:Session
Is a particular fetch profile enabled on this session?- Specified by:
isFetchProfileEnabled
in interfaceSession
- Parameters:
name
- The name of the profile to be checked.- Returns:
- True if fetch profile is enabled; false if not.
- Throws:
UnknownProfileException
- Indicates that the given name does not match any known profile names- See Also:
for discussion of this feature
-
enableFetchProfile
public void enableFetchProfile(String name) throws UnknownProfileException
Description copied from interface:Session
Enable a particular fetch profile on this session. No-op if requested profile is already enabled.- Specified by:
enableFetchProfile
in interfaceSession
- Parameters:
name
- The name of the fetch profile to be enabled.- Throws:
UnknownProfileException
- Indicates that the given name does not match any known profile names- See Also:
for discussion of this feature
-
disableFetchProfile
public void disableFetchProfile(String name) throws UnknownProfileException
Description copied from interface:Session
Disable a particular fetch profile on this session. No-op if requested profile is already disabled.- Specified by:
disableFetchProfile
in interfaceSession
- Parameters:
name
- The name of the fetch profile to be disabled.- Throws:
UnknownProfileException
- Indicates that the given name does not match any known profile names- See Also:
for discussion of this feature
-
getTypeHelper
public TypeHelper getTypeHelper()
Description copied from interface:Session
Convenience access to theTypeHelper
associated with this session'sSessionFactory
. Equivalent to callingSession.getSessionFactory()
.getTypeHelper()
- Specified by:
getTypeHelper
in interfaceSession
- Returns:
- The
TypeHelper
associated with this session'sSessionFactory
-
getLobHelper
public LobHelper getLobHelper()
Description copied from interface:Session
Retrieve this session's helper/delegate for creating LOB instances.- Specified by:
getLobHelper
in interfaceSession
- Returns:
- This session's LOB helper
-
addEventListeners
public void addEventListeners(SessionEventListener... listeners)
Description copied from interface:Session
Add one or more listeners to the Session- Specified by:
addEventListeners
in interfaceSession
- Parameters:
listeners
- The listener(s) to add
-
createQuery
public <T> Query<T> createQuery(String queryString, Class<T> resultType)
Description copied from interface:QueryProducer
Create a typedQuery
instance for the given HQL/JPQL query string.- Specified by:
createQuery
in interfaceEntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in 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:
createQuery
in interfaceEntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceSession
-
createQuery
public Query createQuery(CriteriaUpdate updateQuery)
- Specified by:
createQuery
in interfaceEntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceSession
-
createQuery
public Query createQuery(CriteriaDelete deleteQuery)
- Specified by:
createQuery
in interfaceEntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceSession
-
createNamedQuery
public <T> Query<T> createNamedQuery(String name, Class<T> resultType)
Description copied from interface:QueryProducer
The JPA-defined named, typed query creation method. This form can only represent an HQL/JPQL query (not a native query).- Specified by:
createNamedQuery
in interfaceEntityManager
- Specified by:
createNamedQuery
in interfaceQueryProducer
- Specified by:
createNamedQuery
in 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(String queryString)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given SQL query string.- Specified by:
createSQLQuery
in interfaceQueryProducer
- Specified by:
createSQLQuery
in interfaceSession
- Parameters:
queryString
- The SQL query- Returns:
- The query instance for manipulation and execution
-
getTenantIdentifier
public String getTenantIdentifier()
Description copied from interface:SharedSessionContract
Obtain the tenant identifier associated with this session.- Specified by:
getTenantIdentifier
in interfaceSharedSessionContract
- Returns:
- The tenant identifier associated with this session, or
null
-
close
public void close() throws HibernateException
Description copied from interface:SharedSessionContract
End the session by releasing the JDBC connection and cleaning up.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceEntityManager
- Specified by:
close
in interfaceSharedSessionContract
- Throws:
HibernateException
- Indicates problems cleaning up.
-
isOpen
public boolean isOpen()
Description copied from interface:SharedSessionContract
Check if the session is still open.- Specified by:
isOpen
in interfaceEntityManager
- Specified by:
isOpen
in interfaceSharedSessionContract
- Returns:
- boolean
-
isConnected
public boolean isConnected()
Description copied from interface:SharedSessionContract
Check if the session is currently connected.- Specified by:
isConnected
in interfaceSharedSessionContract
- Returns:
- boolean
-
beginTransaction
public Transaction beginTransaction()
Description copied from interface:SharedSessionContract
Begin a unit of work and return the associatedTransaction
object. If a new underlying transaction is required, begin the transaction. Otherwise continue the new work in the context of the existing underlying transaction.- Specified by:
beginTransaction
in interfaceSharedSessionContract
- Returns:
- a Transaction instance
- See Also:
SharedSessionContract.getTransaction()
-
getTransaction
public Transaction getTransaction()
Description copied from interface:SharedSessionContract
Get theTransaction
instance associated with this session. The concrete type of the returnedTransaction
object is determined by thehibernate.transaction_factory
property.- Specified by:
getTransaction
in interfaceEntityManager
- Specified by:
getTransaction
in interfaceSharedSessionContract
- Returns:
- a Transaction instance
-
createQuery
public Query createQuery(String queryString)
Description copied from interface:QueryProducer
Create aQuery
instance for the given HQL/JPQL query string.- Specified by:
createQuery
in interfaceEntityManager
- Specified by:
createQuery
in interfaceQueryProducer
- Specified by:
createQuery
in interfaceSharedSessionContract
- Parameters:
queryString
- The HQL/JPQL query- Returns:
- The Query instance for manipulation and execution
- See Also:
EntityManager.createQuery(String)
-
getNamedQuery
public Query getNamedQuery(String queryName)
Description copied from interface:QueryProducer
Create aQuery
instance for the named query.- Specified by:
getNamedQuery
in interfaceQueryProducer
- Specified by:
getNamedQuery
in interfaceSharedSessionContract
- Parameters:
queryName
- the name of a pre-defined, named query- Returns:
- The Query instance for manipulation and execution
-
getNamedProcedureCall
public ProcedureCall getNamedProcedureCall(String name)
Description copied from interface:SharedSessionContract
Gets a ProcedureCall based on a named template- Specified by:
getNamedProcedureCall
in 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:SharedSessionContract
Creates a call to a stored procedure.- Specified by:
createStoredProcedureCall
in 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:SharedSessionContract
Creates a call to a stored procedure with specific result set entity mappings. Each class named is considered a "root return".- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.resultClasses
- The entity(s) to map the result on to.- Returns:
- The representation of the procedure call.
-
createStoredProcedureCall
public ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings)
Description copied from interface:SharedSessionContract
Creates a call to a stored procedure with specific result set entity mappings.- Specified by:
createStoredProcedureCall
in interfaceSharedSessionContract
- Parameters:
procedureName
- The name of the procedure.resultSetMappings
- The explicit result set mapping(s) to use for mapping the results- Returns:
- The representation of the procedure call.
-
createCriteria
@Deprecated public Criteria createCriteria(Class persistentClass)
Deprecated.Description copied from interface:SharedSessionContract
CreateCriteria
instance for the given class (entity or subclasses/implementors).- Specified by:
createCriteria
in 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(Class persistentClass, String alias)
Deprecated.Description copied from interface:SharedSessionContract
CreateCriteria
instance for the given class (entity or subclasses/implementors), using a specific alias.- Specified by:
createCriteria
in 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(String entityName)
Deprecated.Description copied from interface:SharedSessionContract
CreateCriteria
instance for the given entity name.- Specified by:
createCriteria
in interfaceSharedSessionContract
- Parameters:
entityName
- The entity name- Returns:
- The criteria instance for manipulation and execution
-
createCriteria
@Deprecated public Criteria createCriteria(String entityName, String alias)
Deprecated.Description copied from interface:SharedSessionContract
CreateCriteria
instance for the given entity name, using a specific alias.- Specified by:
createCriteria
in interfaceSharedSessionContract
- Parameters:
entityName
- The entity namealias
- The alias to use- Returns:
- The criteria instance for manipulation and execution
-
getJdbcBatchSize
public Integer getJdbcBatchSize()
Description copied from interface:SharedSessionContract
Get the Session-level JDBC batch size for the current Session. Overrides the SessionFactory JDBC batch size defined by thehibernate.default_batch_fetch_size
configuration property for the scope of the currentSession
.- Specified by:
getJdbcBatchSize
in interfaceSharedSessionContract
- Returns:
- Session-level JDBC batch size
- See Also:
SessionFactoryOptions.getJdbcBatchSize()
,SessionFactoryBuilder.applyJdbcBatchSize(int)
-
setJdbcBatchSize
public void setJdbcBatchSize(Integer jdbcBatchSize)
Description copied from interface:SharedSessionContract
Set the Session-level JDBC batch size. Overrides the SessionFactory JDBC batch size defined by thehibernate.default_batch_fetch_size
configuration property for the scope of the currentSession
.- Specified by:
setJdbcBatchSize
in 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:SharedSessionContract
Controller for allowing users to perform JDBC related work using the Connection managed by this Session.- Specified by:
doWork
in 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:SharedSessionContract
Controller 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:
doReturningWork
in interfaceSharedSessionContract
- Type Parameters:
T
- The type of the result returned from the work- Parameters:
work
- The work to be performed.- Returns:
- the result from calling
ReturningWork.execute(java.sql.Connection)
. - Throws:
HibernateException
- Generally indicates wrappedSQLException
-
createNamedQuery
public Query createNamedQuery(String name)
Description copied from interface:QueryProducer
The JPA-defined named query creation method. This form can represent an HQL/JPQL query or a native query.- Specified by:
createNamedQuery
in interfaceEntityManager
- Specified by:
createNamedQuery
in 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(String sqlString)
Description copied from interface:QueryProducer
Create a NativeQuery instance for the given native (SQL) query- Specified by:
createNativeQuery
in interfaceEntityManager
- Specified by:
createNativeQuery
in 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(String sqlString, String resultSetMapping)
Description copied from interface:QueryProducer
Create a NativeQuery instance for the given native (SQL) query using implicit mapping to the specified Java type.- Specified by:
createNativeQuery
in interfaceEntityManager
- Specified by:
createNativeQuery
in 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(String name)
Deprecated.Description copied from interface:QueryProducer
Get a NativeQuery instance for a named native SQL query- Specified by:
getNamedSQLQuery
in interfaceQueryProducer
- Parameters:
name
- The name of the pre-defined query- Returns:
- The NativeQuery instance for manipulation and execution
-
getNamedNativeQuery
public NativeQuery getNamedNativeQuery(String name)
Description copied from interface:QueryProducer
Get a NativeQuery instance for a named native SQL query- Specified by:
getNamedNativeQuery
in interfaceQueryProducer
- Parameters:
name
- The name of the pre-defined query- Returns:
- The NativeQuery instance for manipulation and execution
-
remove
public void remove(Object entity)
- Specified by:
remove
in interfaceEntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey)
- Specified by:
find
in interfaceEntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, Map<String,Object> properties)
- Specified by:
find
in interfaceEntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockMode)
- Specified by:
find
in interfaceEntityManager
-
find
public <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockMode, Map<String,Object> properties)
- Specified by:
find
in interfaceEntityManager
-
getReference
public <T> T getReference(Class<T> entityClass, Object primaryKey)
- Specified by:
getReference
in interfaceEntityManager
-
setFlushMode
public void setFlushMode(FlushModeType flushMode)
- Specified by:
setFlushMode
in interfaceEntityManager
-
lock
public void lock(Object entity, LockModeType lockMode)
- Specified by:
lock
in interfaceEntityManager
-
lock
public void lock(Object entity, LockModeType lockMode, Map<String,Object> properties)
- Specified by:
lock
in interfaceEntityManager
-
refresh
public void refresh(Object entity, Map<String,Object> properties)
- Specified by:
refresh
in interfaceEntityManager
-
refresh
public void refresh(Object entity, LockModeType lockMode)
- Specified by:
refresh
in interfaceEntityManager
-
refresh
public void refresh(Object entity, LockModeType lockMode, Map<String,Object> properties)
- Specified by:
refresh
in interfaceEntityManager
-
detach
public void detach(Object entity)
- Specified by:
detach
in interfaceEntityManager
-
contains
public boolean contains(Object entity)
- Specified by:
contains
in interfaceEntityManager
-
getLockMode
public LockModeType getLockMode(Object entity)
- Specified by:
getLockMode
in interfaceEntityManager
-
setProperty
public void setProperty(String propertyName, Object value)
- Specified by:
setProperty
in interfaceEntityManager
-
getProperties
public Map<String,Object> getProperties()
- Specified by:
getProperties
in interfaceEntityManager
-
createNativeQuery
public NativeQuery createNativeQuery(String sqlString, Class resultClass)
Description copied from interface:QueryProducer
Create a NativeQuery instance for the given native (SQL) query using implicit mapping to the specified Java type.- Specified by:
createNativeQuery
in interfaceEntityManager
- Specified by:
createNativeQuery
in 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(String name)
- Specified by:
createNamedStoredProcedureQuery
in interfaceEntityManager
-
createStoredProcedureQuery
public StoredProcedureQuery createStoredProcedureQuery(String procedureName)
- Specified by:
createStoredProcedureQuery
in interfaceEntityManager
-
createStoredProcedureQuery
public StoredProcedureQuery createStoredProcedureQuery(String procedureName, Class... resultClasses)
- Specified by:
createStoredProcedureQuery
in interfaceEntityManager
-
createStoredProcedureQuery
public StoredProcedureQuery createStoredProcedureQuery(String procedureName, String... resultSetMappings)
- Specified by:
createStoredProcedureQuery
in interfaceEntityManager
-
joinTransaction
public void joinTransaction()
- Specified by:
joinTransaction
in interfaceEntityManager
-
isJoinedToTransaction
public boolean isJoinedToTransaction()
- Specified by:
isJoinedToTransaction
in interfaceEntityManager
-
unwrap
public <T> T unwrap(Class<T> cls)
- Specified by:
unwrap
in interfaceEntityManager
-
getDelegate
public Object getDelegate()
- Specified by:
getDelegate
in interfaceEntityManager
-
getEntityManagerFactory
public EntityManagerFactory getEntityManagerFactory()
- Specified by:
getEntityManagerFactory
in interfaceEntityManager
-
getCriteriaBuilder
public CriteriaBuilder getCriteriaBuilder()
- Specified by:
getCriteriaBuilder
in interfaceEntityManager
-
getMetamodel
public Metamodel getMetamodel()
- Specified by:
getMetamodel
in interfaceEntityManager
-
getSession
public Session getSession()
Description copied from interface:HibernateEntityManager
Retrieve a reference to the HibernateSession
used by thisEntityManager
.- Specified by:
getSession
in interfaceHibernateEntityManager
- Returns:
- The session
-
-