public final class SessionImpl extends AbstractSessionImpl implements EventSource
Session to the applicationSessionImplementor to other Hibernate components (SPI)AbstractSessionImpl.JdbcObserverImpl, AbstractSessionImpl.JdbcSessionContextImplLobCreationContext.Callback<T>Session.LockRequestcurrentHibernateTransaction, factory, wrapperOptions| Modifier and Type | Method and Description |
|---|---|
void |
addEventListeners(SessionEventListener... listeners)
Add one or more listeners to the Session
|
void |
afterOperation(boolean success)
Check if there is a Hibernate or JTA transaction in progress and,
if there is not, flush if necessary, make sure the connection has
been committed (if it is not in autocommit mode) and run the after
completion processing
|
void |
afterScrollOperation() |
void |
afterTransactionBegin()
A after-begin callback from the coordinator to its owner.
|
void |
afterTransactionCompletion(boolean successful,
boolean delayed)
An after-completion callback to the owner.
|
protected boolean |
autoFlushIfRequired(Set querySpaces)
detect in-memory changes, determine if the changes are to tables
named in the query and, if so, complete execution the flush
|
void |
beforeTransactionCompletion()
A before-completion callback to the owner.
|
Transaction |
beginTransaction()
Begin a unit of work and return the associated
Transaction object. |
String |
bestGuessEntityName(Object object)
The best guess entity name for an entity not in an association
|
Session.LockRequest |
buildLockRequest(LockOptions lockOptions)
Build a LockRequest that specifies the LockMode, pessimistic lock timeout and lock scope.
|
<T> org.hibernate.internal.SessionImpl.IdentifierLoadAccessImpl<T> |
byId(Class<T> entityClass)
Create an
IdentifierLoadAccess instance to retrieve the specified entity by
primary key. |
org.hibernate.internal.SessionImpl.IdentifierLoadAccessImpl |
byId(String entityName)
Create an
IdentifierLoadAccess instance to retrieve the specified entity type by
primary key. |
<T> MultiIdentifierLoadAccess<T> |
byMultipleIds(Class<T> entityClass)
Create a
MultiIdentifierLoadAccess instance to retrieve multiple entities at once
as specified by primary key values. |
MultiIdentifierLoadAccess |
byMultipleIds(String entityName)
Create a
MultiIdentifierLoadAccess instance to retrieve multiple entities at once
as specified by primary key values. |
<T> NaturalIdLoadAccess<T> |
byNaturalId(Class<T> entityClass)
Create an
NaturalIdLoadAccess instance to retrieve the specified entity by
its natural id. |
NaturalIdLoadAccess |
byNaturalId(String entityName)
Create an
NaturalIdLoadAccess instance to retrieve the specified entity by
its natural id. |
<T> SimpleNaturalIdLoadAccess<T> |
bySimpleNaturalId(Class<T> entityClass)
Create an
SimpleNaturalIdLoadAccess instance to retrieve the specified entity by
its simple (single attribute) natural id. |
SimpleNaturalIdLoadAccess |
bySimpleNaturalId(String entityName)
Create an
SimpleNaturalIdLoadAccess 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.
|
Connection |
connection() |
boolean |
contains(Object object)
Check if this instance is associated with this Session.
|
Criteria |
createCriteria(Class persistentClass)
Create
Criteria instance for the given class (entity or subclasses/implementors). |
Criteria |
createCriteria(Class persistentClass,
String alias)
Create
Criteria instance for the given class (entity or subclasses/implementors), using a specific
alias. |
Criteria |
createCriteria(String entityName)
Create
Criteria instance for the given entity name. |
Criteria |
createCriteria(String entityName,
String alias)
Create
Criteria instance for the given entity name, using a specific alias. |
Query |
createFilter(Object collection,
String queryString)
Create a
Query instance for the given collection and filter string. |
Query |
createQuery(String queryString)
Create a
Query instance for the given HQL query string. |
SQLQuery |
createSQLQuery(String sql)
Create a
SQLQuery 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.
|
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 |
delete(String entityName,
Object object,
boolean isCascadeDeleteEnabled,
Set transientEntities)
Cascade delete an entity instance
|
void |
disableFetchProfile(String name)
Disable a particular fetch profile on this session.
|
void |
disableFilter(String filterName)
Disable the named filter for the current session.
|
void |
disableTransactionAutoJoin()
Disable automatic transaction joining.
|
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 any hard references to the entity that are held by the infrastructure
(references held by application or other persistent instances are okay)
|
int |
executeNativeUpdate(NativeSQLQuerySpecification nativeQuerySpecification,
QueryParameters queryParameters)
Execute a native SQL update or delete query
|
int |
executeUpdate(String query,
QueryParameters queryParameters)
Execute a HQL update or delete query
|
void |
flush()
Force this session to flush.
|
void |
flushBeforeTransactionCompletion() |
void |
forceFlush(EntityEntry entityEntry)
Force an immediate flush
|
<T> T |
get(Class<T> entityClass,
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> entityClass,
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> entityClass,
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.
|
ActionQueue |
getActionQueue()
Get the ActionQueue for this session
|
CacheMode |
getCacheMode()
Get the current cache mode.
|
Serializable |
getContextEntityIdentifier(Object object)
Get the id value for an object that is actually associated with the session.
|
LockMode |
getCurrentLockMode(Object object)
Determine the current lock mode of the given object.
|
int |
getDontFlushFromFind() |
Filter |
getEnabledFilter(String filterName)
Retrieve a currently enabled filter by name.
|
String |
getEntityName(Object object)
Return the entity name for a persistent entity.
|
EntityPersister |
getEntityPersister(String entityName,
Object object)
Get the EntityPersister for any instance
|
Object |
getEntityUsingInterceptor(EntityKey key)
Get the entity instance associated with the given Key,
calling the Interceptor if necessary
|
SessionEventListenerManagerImpl |
getEventListenerManager() |
FlushMode |
getFlushMode()
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.
|
Interceptor |
getInterceptor()
Retrieves the interceptor currently in use by this event source.
|
JdbcCoordinator |
getJdbcCoordinator() |
JdbcSessionContext |
getJdbcSessionContext() |
LoadQueryInfluencers |
getLoadQueryInfluencers()
Get the load query influencers associated with this session.
|
LobHelper |
getLobHelper()
Retrieve this session's helper/delegate for creating LOB instances.
|
Query |
getNamedQuery(String queryName)
Create a
Query instance for the named query string defined in the metadata. |
PersistenceContext |
getPersistenceContext()
Get the persistence context for this session
|
SessionFactoryImplementor |
getSessionFactory()
Get the session factory which created this session.
|
SessionStatistics |
getStatistics()
Get the statistics for this session.
|
long |
getTimestamp()
System time before the start of the transaction
|
TransactionCoordinator |
getTransactionCoordinator()
Retrieve access to the session's transaction coordinator.
|
TypeHelper |
getTypeHelper()
Convenience access to the
TypeHelper associated with this session's SessionFactory. |
String |
guessEntityName(Object object)
The guessed entity name for an entity not in an association
|
Object |
immediateLoad(String entityName,
Serializable id)
Load the data for the object with the specified id into a newly created object.
|
void |
initializeCollection(PersistentCollection collection,
boolean writing)
Initialize the collection (if not already initialized)
|
Object |
instantiate(EntityPersister persister,
Serializable id)
give the interceptor an opportunity to override the default instantiation
|
Object |
instantiate(String entityName,
Serializable id)
Instantiate the entity class, initializing with the given identifier
|
Object |
internalLoad(String entityName,
Serializable id,
boolean eager,
boolean nullable)
Load an instance without checking if it was deleted.
|
boolean |
isAutoCloseSessionEnabled() |
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 |
isEventSource() |
boolean |
isFetchProfileEnabled(String name)
Is a particular fetch profile enabled on this session?
|
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:
|
boolean |
isTransactionInProgress()
Does this Session have an active Hibernate transaction
or is there a JTA transaction in progress?
|
Iterator |
iterate(String query,
QueryParameters queryParameters)
Execute an iterate() query
|
Iterator |
iterateFilter(Object collection,
String filter,
QueryParameters queryParameters)
Iterate a filter
|
List |
list(Criteria criteria)
Execute a criteria query
|
List |
list(String query,
QueryParameters queryParameters)
Execute a find() query
|
List |
listCustomQuery(CustomQuery customQuery,
QueryParameters queryParameters)
Execute an SQL Query
|
List |
listFilter(Object collection,
String filter,
QueryParameters queryParameters)
Execute a filter
|
<T> T |
load(Class<T> entityClass,
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> entityClass,
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> entityClass,
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 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 |
merge(String entityName,
Object object,
Map copiedAlready)
Cascade merge an entity instance
|
void |
persist(Object object)
Make a transient instance persistent.
|
void |
persist(String entityName,
Object object)
Make a transient instance persistent.
|
void |
persist(String entityName,
Object object,
Map copiedAlready)
Cascade persist an entity instance
|
void |
persistOnFlush(Object object) |
void |
persistOnFlush(String entityName,
Object object) |
void |
persistOnFlush(String entityName,
Object object,
Map copiedAlready)
Cascade persist an entity instance during the flush process
|
void |
reconnect(Connection conn)
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 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 |
refresh(String entityName,
Object object,
Map refreshedAlready)
Cascade refresh an entity instance
|
void |
removeOrphanBeforeUpdates(String entityName,
Object child)
A specialized type of deletion for orphan removal that must occur prior to queued inserts and updates.
|
void |
replicate(Object obj,
ReplicationMode replicationMode)
Persist the state of the given detached instance, reusing the current
identifier value.
|
void |
replicate(String entityName,
Object obj,
ReplicationMode replicationMode)
Persist the state of the given detached instance, reusing the current
identifier value.
|
Serializable |
save(Object obj)
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)
Either
Session.save(Object) or Session.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 obj)
Either
Session.save(String, Object) or Session.update(String, Object)
the given instance, depending upon resolution of the unsaved-value checks
(see the manual for discussion of unsaved-value checking). |
ScrollableResults |
scroll(Criteria criteria,
ScrollMode scrollMode)
Execute a criteria query
|
ScrollableResults |
scroll(String query,
QueryParameters queryParameters)
Execute a scroll() query
|
ScrollableResults |
scrollCustomQuery(CustomQuery customQuery,
QueryParameters queryParameters)
Execute an SQL Query
|
SharedSessionBuilder |
sessionWithOptions()
Obtain a
Session builder with the ability to grab certain information from this session. |
void |
setAutoClear(boolean enabled)
Enable/disable automatic cache clearing from after transaction
completion (for EJB3)
|
void |
setCacheMode(CacheMode cacheMode)
Set the cache mode.
|
void |
setDefaultReadOnly(boolean defaultReadOnly)
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(FlushMode flushMode)
Set the flush mode for this session.
|
void |
setReadOnly(Object entity,
boolean readOnly)
Set an unmodified persistent object to read-only mode, or a read-only
object to modifiable mode.
|
boolean |
shouldAutoClose() |
boolean |
shouldAutoJoinTransaction()
Indicates whether an active transaction should be automatically joined.
|
String |
toString() |
void |
update(Object obj)
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.
|
createQuery, createSQLQuery, errorIfClosed, execute, generateEntityKey, getFactory, getHQLQueryPlan, getJdbcConnectionAccess, getNamedProcedureCall, getNamedSQLQuery, getNativeSQLQueryPlan, getSessionIdentifier, getTenantIdentifier, getTransaction, getTransactionCoordinatorBuilder, getWrapperOptions, isClosed, list, scroll, setClosedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcreateQuery, createSQLQuery, generateEntityKey, getFactory, getJdbcConnectionAccess, getNamedSQLQuery, getTenantIdentifier, isClosed, list, scrollexecutegetWrapperOptionsgetNamedProcedureCall, getTenantIdentifier, getTransactionpublic SharedSessionBuilder sessionWithOptions()
SessionSession builder with the ability to grab certain information from this session.sessionWithOptions in interface Sessionpublic void clear()
Sessionpublic long getTimestamp()
SessionImplementorgetTimestamp in interface SessionImplementorpublic void close()
throws HibernateException
SessionSession.disconnect() it.close in interface Closeableclose in interface AutoCloseableclose in interface SessionHibernateException - Indicates problems cleaning up.public boolean isAutoCloseSessionEnabled()
isAutoCloseSessionEnabled in interface SessionImplementorpublic boolean shouldAutoJoinTransaction()
TransactionCoordinatorBuilder.TransactionCoordinatorOptionsshouldAutoJoinTransaction in interface TransactionCoordinatorBuilder.TransactionCoordinatorOptionsshouldAutoJoinTransaction in class AbstractSessionImpltrue indicates the active transaction should be auto joined; false
indicates it should not (until TransactionCoordinator.explicitJoin() is called).public boolean isOpen()
SessionisOpen in interface SessionImplementorisOpen in interface Sessionpublic boolean shouldAutoClose()
shouldAutoClose in interface SessionImplementorpublic Connection connection() throws HibernateException
connection in interface SessionImplementorHibernateExceptionpublic boolean isConnected()
SessionisConnected in interface SessionImplementorisConnected in interface Sessionpublic boolean isTransactionInProgress()
SessionImplementorisTransactionInProgress in interface SessionImplementorpublic Connection disconnect() throws HibernateException
Sessiondisconnect in interface SessionnullHibernateExceptionSession.reconnect(Connection)public void reconnect(Connection conn) throws HibernateException
Sessionreconnect in interface Sessionconn - a JDBC connectionHibernateExceptionSession.disconnect()public void setAutoClear(boolean enabled)
SessionImplementorsetAutoClear in interface SessionImplementorpublic void disableTransactionAutoJoin()
SessionImplementorSynchronization).
JPA however defines an explicit join transaction operation.
See javax.persistence.EntityManager#joinTransactiondisableTransactionAutoJoin in interface SessionImplementorpublic void afterOperation(boolean success)
success - Was the operation a successpublic SessionEventListenerManagerImpl getEventListenerManager()
getEventListenerManager in interface SessionImplementorpublic void addEventListeners(SessionEventListener... listeners)
SessionaddEventListeners in interface Sessionlisteners - The listener(s) to addpublic LockMode getCurrentLockMode(Object object) throws HibernateException
SessiongetCurrentLockMode in interface Sessionobject - a persistent instanceHibernateExceptionpublic Object getEntityUsingInterceptor(EntityKey key) throws HibernateException
SessionImplementorgetEntityUsingInterceptor in interface SessionImplementorHibernateExceptionpublic void saveOrUpdate(Object object) throws HibernateException
SessionSession.save(Object) or Session.update(Object) the given
instance, depending upon resolution of the unsaved-value checks (see the
manual for discussion of unsaved-value checking).
This operation cascades to associated instances if the association is mapped
with cascade="save-update"saveOrUpdate in interface Sessionobject - a transient or detached instance containing new or updated stateHibernateExceptionSession.save(java.lang.Object),
Session.update(Object object)public void saveOrUpdate(String entityName, Object obj) throws HibernateException
SessionSession.save(String, Object) or Session.update(String, Object)
the given instance, depending upon resolution of the unsaved-value checks
(see the manual for discussion of unsaved-value checking).
This operation cascades to associated instances if the association is mapped
with cascade="save-update"saveOrUpdate in interface SessionentityName - The entity nameobj - a transient or detached instance containing new or updated stateHibernateExceptionSession.save(String,Object),
Session.update(String,Object)public Serializable save(Object obj) throws HibernateException
Sessioncascade="save-update"save in interface Sessionobj - a transient instance of a persistent classHibernateExceptionpublic Serializable save(String entityName, Object object) throws HibernateException
Sessioncascade="save-update"save in interface SessionentityName - The entity nameobject - a transient instance of a persistent classHibernateExceptionpublic void update(Object obj) throws HibernateException
Sessioncascade="save-update"update in interface Sessionobj - a detached instance containing updated stateHibernateExceptionpublic void update(String entityName, Object object) throws HibernateException
Sessioncascade="save-update"update in interface SessionentityName - The entity nameobject - a detached instance containing updated stateHibernateExceptionpublic void lock(String entityName, Object object, LockMode lockMode) throws HibernateException
SessionSession.LockRequest.lock(String, Object) via Session.buildLockRequest(LockOptions)lock in interface SessionentityName - The name of the entityobject - a persistent or transient instancelockMode - the lock levelHibernateExceptionSession.buildLockRequest(LockOptions),
Session.LockRequest.lock(String, Object)public Session.LockRequest buildLockRequest(LockOptions lockOptions)
Sessionsession.buildLockRequest().setLockMode(LockMode.PESSIMISTIC_WRITE).setTimeOut(60000).lock(entity);buildLockRequest in interface SessionlockOptions - contains the lock levelpublic void lock(Object object, LockMode lockMode) throws HibernateException
SessionSession.LockRequest.lock(Object) via Session.buildLockRequest(LockOptions)lock in interface Sessionobject - a persistent or transient instancelockMode - the lock levelHibernateExceptionSession.buildLockRequest(LockOptions),
Session.LockRequest.lock(Object)public void persist(String entityName, Object object) throws HibernateException
Sessioncascade="persist"
The semantics of this method are defined by JSR-220.persist in interface SessionentityName - The entity nameobject - a transient instance to be made persistentHibernateExceptionpublic void persist(Object object) throws HibernateException
Sessioncascade="persist"
The semantics of this method are defined by JSR-220.persist in interface Sessionobject - a transient instance to be made persistentHibernateExceptionpublic void persist(String entityName, Object object, Map copiedAlready) throws HibernateException
EventSourcepersist in interface EventSourceHibernateExceptionpublic void persistOnFlush(String entityName, Object object) throws HibernateException
HibernateExceptionpublic void persistOnFlush(Object object) throws HibernateException
HibernateExceptionpublic void persistOnFlush(String entityName, Object object, Map copiedAlready) throws HibernateException
EventSourcepersistOnFlush in interface EventSourceHibernateExceptionpublic Object merge(String entityName, Object object) throws HibernateException
Sessioncascade="merge"
The semantics of this method are defined by JSR-220.merge in interface SessionentityName - The entity nameobject - a detached instance with state to be copiedHibernateExceptionpublic Object merge(Object object) throws HibernateException
Sessioncascade="merge"
The semantics of this method are defined by JSR-220.merge in interface Sessionobject - a detached instance with state to be copiedHibernateExceptionpublic void merge(String entityName, Object object, Map copiedAlready) throws HibernateException
EventSourcemerge in interface EventSourceHibernateExceptionpublic void delete(Object object) throws HibernateException
Sessioncascade="delete"delete in interface Sessionobject - the instance to be removedHibernateExceptionpublic void delete(String entityName, Object object) throws HibernateException
Sessioncascade="delete"delete in interface SessionentityName - The entity name for the instance to be removed.object - the instance to be removedHibernateExceptionpublic void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, Set transientEntities) throws HibernateException
EventSourcedelete in interface EventSourceHibernateExceptionpublic void removeOrphanBeforeUpdates(String entityName, Object child)
EventSourceremoveOrphanBeforeUpdates in interface EventSourcepublic void load(Object object, Serializable id) throws HibernateException
Sessionload in interface Sessionobject - an "empty" instance of the persistent classid - a valid identifier of an existing persistent instance of the classHibernateExceptionpublic <T> T load(Class<T> entityClass, Serializable id) throws HibernateException
Sessionload in interface SessionentityClass - a persistent classid - a valid identifier of an existing persistent instance of the classHibernateExceptionpublic Object load(String entityName, Serializable id) throws HibernateException
Sessionload in interface SessionentityName - a persistent classid - a valid identifier of an existing persistent instance of the classHibernateExceptionpublic <T> T get(Class<T> entityClass, Serializable id) throws HibernateException
Sessionget in interface SessionentityClass - The entity typeid - an identifierHibernateExceptionpublic Object get(String entityName, Serializable id) throws HibernateException
Sessionget in interface SessionentityName - the entity nameid - an identifierHibernateExceptionpublic Object immediateLoad(String entityName, Serializable id) throws HibernateException
immediateLoad in interface SessionImplementorHibernateExceptionpublic final Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) throws HibernateException
SessionImplementorinternalLoad in interface SessionImplementorHibernateExceptionpublic <T> T load(Class<T> entityClass, Serializable id, LockMode lockMode) throws HibernateException
SessionSession.load(Class, Serializable, LockOptions)load in interface SessionentityClass - a persistent classid - a valid identifier of an existing persistent instance of the classlockMode - the lock levelHibernateExceptionSession.load(Class, Serializable, LockOptions)public <T> T load(Class<T> entityClass, Serializable id, LockOptions lockOptions) throws HibernateException
Sessionload in interface SessionentityClass - a persistent classid - a valid identifier of an existing persistent instance of the classlockOptions - contains the lock levelHibernateExceptionpublic Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException
SessionSession.load(String, Serializable, LockOptions)load in interface SessionentityName - a persistent classid - a valid identifier of an existing persistent instance of the classlockMode - the lock levelHibernateExceptionSession.load(String, Serializable, LockOptions)public Object load(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException
Sessionload in interface SessionentityName - a persistent classid - a valid identifier of an existing persistent instance of the classlockOptions - contains the lock levelHibernateExceptionpublic <T> T get(Class<T> entityClass, Serializable id, LockMode lockMode) throws HibernateException
SessionSession.get(Class, Serializable, LockOptions)get in interface SessionentityClass - The entity typeid - an identifierlockMode - the lock modeHibernateExceptionSession.get(Class, Serializable, LockOptions)public <T> T get(Class<T> entityClass, Serializable id, LockOptions lockOptions) throws HibernateException
Sessionget in interface SessionentityClass - The entity typeid - an identifierlockOptions - the lock modeHibernateExceptionpublic Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException
SessionSession.get(String, Serializable, LockOptions)get in interface SessionentityName - the entity nameid - an identifierlockMode - the lock modeHibernateExceptionSession.get(String, Serializable, LockOptions)public Object get(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException
Sessionget in interface SessionentityName - the entity nameid - an identifierlockOptions - contains the lock modeHibernateExceptionpublic org.hibernate.internal.SessionImpl.IdentifierLoadAccessImpl byId(String entityName)
SessionIdentifierLoadAccess instance to retrieve the specified entity type by
primary key.public <T> org.hibernate.internal.SessionImpl.IdentifierLoadAccessImpl<T> byId(Class<T> entityClass)
SessionIdentifierLoadAccess instance to retrieve the specified entity by
primary key.public <T> MultiIdentifierLoadAccess<T> byMultipleIds(Class<T> entityClass)
SessionMultiIdentifierLoadAccess instance to retrieve multiple entities at once
as specified by primary key values.byMultipleIds in interface SessionentityClass - The entity type to be retrievedpublic MultiIdentifierLoadAccess byMultipleIds(String entityName)
SessionMultiIdentifierLoadAccess instance to retrieve multiple entities at once
as specified by primary key values.byMultipleIds in interface SessionentityName - The entity name of the entity type to be retrievedpublic NaturalIdLoadAccess byNaturalId(String entityName)
SessionNaturalIdLoadAccess instance to retrieve the specified entity by
its natural id.byNaturalId in interface SessionentityName - The entity name of the entity type to be retrievedpublic <T> NaturalIdLoadAccess<T> byNaturalId(Class<T> entityClass)
SessionNaturalIdLoadAccess instance to retrieve the specified entity by
its natural id.byNaturalId in interface SessionentityClass - The entity type to be retrievedpublic SimpleNaturalIdLoadAccess bySimpleNaturalId(String entityName)
SessionSimpleNaturalIdLoadAccess instance to retrieve the specified entity by
its natural id.bySimpleNaturalId in interface SessionentityName - The entity name of the entity type to be retrievedpublic <T> SimpleNaturalIdLoadAccess<T> bySimpleNaturalId(Class<T> entityClass)
SessionSimpleNaturalIdLoadAccess instance to retrieve the specified entity by
its simple (single attribute) natural id.bySimpleNaturalId in interface SessionentityClass - The entity type to be retrievedpublic void refresh(Object object) throws HibernateException
Sessionrefresh in interface Sessionobject - a persistent or detached instanceHibernateExceptionpublic void refresh(String entityName, Object object) throws HibernateException
Sessionrefresh in interface SessionentityName - a persistent classobject - a persistent or detached instanceHibernateExceptionpublic void refresh(Object object, LockMode lockMode) throws HibernateException
SessionSession.refresh(Object, LockOptions)refresh in interface Sessionobject - a persistent or detached instancelockMode - the lock mode to useHibernateExceptionSession.refresh(Object, LockOptions)public void refresh(Object object, LockOptions lockOptions) throws HibernateException
Sessionrefresh in interface Sessionobject - a persistent or detached instancelockOptions - contains the lock mode to useHibernateExceptionpublic void refresh(String entityName, Object object, LockOptions lockOptions) throws HibernateException
Sessionrefresh in interface SessionentityName - a persistent classobject - a persistent or detached instancelockOptions - contains the lock mode to useHibernateExceptionpublic void refresh(String entityName, Object object, Map refreshedAlready) throws HibernateException
EventSourcerefresh in interface EventSourceHibernateExceptionpublic void replicate(Object obj, ReplicationMode replicationMode) throws HibernateException
Sessioncascade="replicate"replicate in interface Sessionobj - a detached instance of a persistent classreplicationMode - The replication mode to useHibernateExceptionpublic void replicate(String entityName, Object obj, ReplicationMode replicationMode) throws HibernateException
Sessioncascade="replicate"replicate in interface SessionentityName - The entity nameobj - a detached instance of a persistent classreplicationMode - The replication mode to useHibernateExceptionpublic void evict(Object object) throws HibernateException
evict in interface Sessionobject - The entity to evictHibernateExceptionprotected boolean autoFlushIfRequired(Set querySpaces) throws HibernateException
HibernateExceptionpublic boolean isDirty()
throws HibernateException
SessionisDirty in interface SessionHibernateException - could not perform dirtying checkingpublic void flush()
throws HibernateException
SessionSession.setFlushMode(FlushMode),
Transaction.commit() calls this method).
Flushing is the process of synchronizing the underlying persistent
store with persistable state held in memory.flush in interface SessionImplementorflush in interface SessionHibernateException - Indicates problems flushing the session or
talking to the database.public void forceFlush(EntityEntry entityEntry) throws HibernateException
EventSourceforceFlush in interface EventSourceHibernateExceptionpublic List list(String query, QueryParameters queryParameters) throws HibernateException
SessionImplementorlist in interface SessionImplementorHibernateExceptionpublic int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException
SessionImplementorexecuteUpdate in interface SessionImplementorHibernateExceptionpublic int executeNativeUpdate(NativeSQLQuerySpecification nativeQuerySpecification, QueryParameters queryParameters) throws HibernateException
SessionImplementorexecuteNativeUpdate in interface SessionImplementorHibernateExceptionpublic Iterator iterate(String query, QueryParameters queryParameters) throws HibernateException
SessionImplementoriterate in interface SessionImplementorHibernateExceptionpublic ScrollableResults scroll(String query, QueryParameters queryParameters) throws HibernateException
SessionImplementorscroll in interface SessionImplementorHibernateExceptionpublic Query createFilter(Object collection, String queryString)
SessionQuery instance for the given collection and filter string. Contains an implicit FROM
element named this which refers to the defined table for the collection elements, as well as an implicit
WHERE restriction for this particular collection instance's key value.createFilter in interface Sessioncollection - a persistent collectionqueryString - a Hibernate query fragment.public Query getNamedQuery(String queryName) throws MappingException
SharedSessionContractQuery instance for the named query string defined in the metadata.getNamedQuery in interface SessionImplementorgetNamedQuery in interface SharedSessionContractgetNamedQuery in class AbstractSessionImplqueryName - the name of a query defined externallyMappingExceptionpublic Object instantiate(String entityName, Serializable id) throws HibernateException
SessionImplementorinstantiate in interface SessionImplementorHibernateExceptionpublic Object instantiate(EntityPersister persister, Serializable id) throws HibernateException
instantiate in interface EventSourceHibernateExceptionpublic void setFlushMode(FlushMode flushMode)
SessionFlushMode.MANUAL at the start of the session (in
order to achieve some extra performance).setFlushMode in interface SessionImplementorsetFlushMode in interface SessionflushMode - the new flush modeFlushModepublic FlushMode getFlushMode()
SessiongetFlushMode in interface SessionImplementorgetFlushMode in interface Sessionpublic CacheMode getCacheMode()
SessiongetCacheMode in interface SessionImplementorgetCacheMode in interface Sessionpublic void setCacheMode(CacheMode cacheMode)
SessionsetCacheMode in interface SessionImplementorsetCacheMode in interface SessioncacheMode - The new cache mode.public Transaction beginTransaction() throws HibernateException
SharedSessionContractTransaction object. If a new underlying transaction is
required, begin the transaction. Otherwise continue the new work in the context of the existing underlying
transaction.beginTransaction in interface SharedSessionContractHibernateExceptionSharedSessionContract.getTransaction()public EntityPersister getEntityPersister(String entityName, Object object)
SessionImplementorgetEntityPersister in interface SessionImplementorentityName - optional entity nameobject - the entity instancepublic Serializable getIdentifier(Object object) throws HibernateException
SessiongetIdentifier in interface Sessionobject - a persistent instanceTransientObjectException - if the instance is transient or associated with
a different sessionHibernateExceptionpublic Serializable getContextEntityIdentifier(Object object)
getContextEntityIdentifier in interface SessionImplementorpublic List listFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException
SessionImplementorlistFilter in interface SessionImplementorHibernateExceptionpublic Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException
SessionImplementoriterateFilter in interface SessionImplementorHibernateExceptionpublic Criteria createCriteria(Class persistentClass, String alias)
SharedSessionContractCriteria instance for the given class (entity or subclasses/implementors), using a specific
alias.createCriteria in interface SharedSessionContractpersistentClass - The class, which is an entity, or has entity subclasses/implementorsalias - The alias to usepublic Criteria createCriteria(String entityName, String alias)
SharedSessionContractCriteria instance for the given entity name, using a specific alias.createCriteria in interface SharedSessionContractentityName - The entity namealias - The alias to usepublic Criteria createCriteria(Class persistentClass)
SharedSessionContractCriteria instance for the given class (entity or subclasses/implementors).createCriteria in interface SharedSessionContractpersistentClass - The class, which is an entity, or has entity subclasses/implementorspublic Criteria createCriteria(String entityName)
SharedSessionContractCriteria instance for the given entity name.createCriteria in interface SharedSessionContractentityName - The entity namepublic ScrollableResults scroll(Criteria criteria, ScrollMode scrollMode)
SessionImplementorscroll in interface SessionImplementorpublic List list(Criteria criteria) throws HibernateException
SessionImplementorlist in interface SessionImplementorHibernateExceptionpublic boolean contains(Object object)
Sessionpublic Query createQuery(String queryString)
SharedSessionContractQuery instance for the given HQL query string.createQuery in interface SharedSessionContractcreateQuery in class AbstractSessionImplqueryString - The HQL querypublic SQLQuery createSQLQuery(String sql)
SharedSessionContractSQLQuery instance for the given SQL query string.createSQLQuery in interface SharedSessionContractcreateSQLQuery in class AbstractSessionImplsql - The SQL querypublic ProcedureCall createStoredProcedureCall(String procedureName)
SharedSessionContractcreateStoredProcedureCall in interface SharedSessionContractcreateStoredProcedureCall in class AbstractSessionImplprocedureName - The name of the procedure.public ProcedureCall createStoredProcedureCall(String procedureName, String... resultSetMappings)
SharedSessionContractcreateStoredProcedureCall in interface SharedSessionContractcreateStoredProcedureCall in class AbstractSessionImplprocedureName - The name of the procedure.resultSetMappings - The explicit result set mapping(s) to use for mapping the resultspublic ProcedureCall createStoredProcedureCall(String procedureName, Class... resultClasses)
SharedSessionContractcreateStoredProcedureCall in interface SharedSessionContractcreateStoredProcedureCall in class AbstractSessionImplprocedureName - The name of the procedure.resultClasses - The entity(s) to map the result on to.public ScrollableResults scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException
SessionImplementorscrollCustomQuery in interface SessionImplementorHibernateExceptionpublic List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException
SessionImplementorlistCustomQuery in interface SessionImplementorHibernateExceptionpublic SessionFactoryImplementor getSessionFactory()
SessiongetSessionFactory in interface SessionSessionFactorypublic void initializeCollection(PersistentCollection collection, boolean writing) throws HibernateException
SessionImplementorinitializeCollection in interface SessionImplementorHibernateExceptionpublic String bestGuessEntityName(Object object)
SessionImplementorbestGuessEntityName in interface SessionImplementorpublic String getEntityName(Object object)
SessiongetEntityName in interface Sessionobject - a persistent entitypublic String guessEntityName(Object object) throws HibernateException
SessionImplementorguessEntityName in interface SessionImplementorHibernateExceptionpublic void cancelQuery()
throws HibernateException
SessioncancelQuery in interface SessionHibernateException - There was a problem canceling the querypublic Interceptor getInterceptor()
SessionImplementorgetInterceptor in interface SessionImplementorpublic int getDontFlushFromFind()
getDontFlushFromFind in interface SessionImplementorpublic ActionQueue getActionQueue()
EventSourcegetActionQueue in interface EventSourcepublic PersistenceContext getPersistenceContext()
SessionImplementorgetPersistenceContext in interface SessionImplementorpublic SessionStatistics getStatistics()
SessiongetStatistics in interface Sessionpublic boolean isEventSource()
isEventSource in interface SessionImplementorpublic boolean isDefaultReadOnly()
SessionisDefaultReadOnly in interface SessionSession.isReadOnly(Object)public void setDefaultReadOnly(boolean defaultReadOnly)
SessionsetDefaultReadOnly in interface SessiondefaultReadOnly - true, the default for loaded entities/proxies is read-only;
false, the default for loaded entities/proxies is modifiableTo override this session's read-only/modifiable setting for entities
and proxies loaded by a Query:,
Query.setReadOnly(boolean)public boolean isReadOnly(Object entityOrProxy)
SessionisReadOnly in interface SessionentityOrProxy - an entity or HibernateProxytrue if the entity or proxy is read-only, false if the entity or proxy is modifiable.Session.isDefaultReadOnly()public void setReadOnly(Object entity, boolean readOnly)
SessionsetReadOnly in interface Sessionentity - an entity or HibernateProxyreadOnly - true if the entity or proxy should be made read-only; false if the entity or
proxy should be made modifiableTo override this session's read-only/modifiable setting for entities
and proxies loaded by a Query:,
Query.setReadOnly(boolean)public void doWork(Work work) throws HibernateException
SessiondoWork in interface Sessionwork - The work to be performed.HibernateException - Generally indicates wrapped SQLExceptionpublic <T> T doReturningWork(ReturningWork<T> work) throws HibernateException
SessionReturningWork.execute(java.sql.Connection) call.doReturningWork in interface SessionT - The type of the result returned from the workwork - The work to be performed.ReturningWork.execute(java.sql.Connection).HibernateException - Generally indicates wrapped SQLExceptionpublic void afterScrollOperation()
afterScrollOperation in interface SessionImplementorpublic TransactionCoordinator getTransactionCoordinator()
SessionImplementorgetTransactionCoordinator in interface SessionImplementorpublic JdbcCoordinator getJdbcCoordinator()
getJdbcCoordinator in interface SessionImplementorpublic LoadQueryInfluencers getLoadQueryInfluencers()
SessionImplementorgetLoadQueryInfluencers in interface SessionImplementorpublic Filter getEnabledFilter(String filterName)
SessiongetEnabledFilter in interface SessionfilterName - The name of the filter to be retrieved.public Filter enableFilter(String filterName)
SessionenableFilter in interface SessionfilterName - The name of the filter to be enabled.public void disableFilter(String filterName)
SessiondisableFilter in interface SessionfilterName - The name of the filter to be disabled.public boolean isFetchProfileEnabled(String name) throws UnknownProfileException
SessionisFetchProfileEnabled in interface Sessionname - The name of the profile to be checked.UnknownProfileException - Indicates that the given name does not
match any known profile namesfor discussion of this featurepublic void enableFetchProfile(String name) throws UnknownProfileException
SessionenableFetchProfile in interface Sessionname - The name of the fetch profile to be enabled.UnknownProfileException - Indicates that the given name does not
match any known profile namesfor discussion of this featurepublic void disableFetchProfile(String name) throws UnknownProfileException
SessiondisableFetchProfile in interface Sessionname - The name of the fetch profile to be disabled.UnknownProfileException - Indicates that the given name does not
match any known profile namesfor discussion of this featurepublic TypeHelper getTypeHelper()
SessionTypeHelper associated with this session's SessionFactory.
Equivalent to calling Session.getSessionFactory().getTypeHelper()getTypeHelper in interface SessionTypeHelper associated with this session's SessionFactorypublic LobHelper getLobHelper()
SessiongetLobHelper in interface Sessionpublic JdbcSessionContext getJdbcSessionContext()
getJdbcSessionContext in interface JdbcSessionOwnerpublic void beforeTransactionCompletion()
JdbcSessionOwnerbeforeTransactionCompletion in interface JdbcSessionOwnerpublic void afterTransactionCompletion(boolean successful,
boolean delayed)
JdbcSessionOwnerafterTransactionCompletion in interface JdbcSessionOwnersuccessful - Was the transaction successful?delayed - Is this a delayed after transaction completion call (aka after a timeout)?public void afterTransactionBegin()
JdbcSessionOwnerafterTransactionBegin in interface JdbcSessionOwnerpublic void flushBeforeTransactionCompletion()
flushBeforeTransactionCompletion in interface JdbcSessionOwnerCopyright © 2017 JBoss by Red Hat. All rights reserved.