Package org.hibernate.impl
Class SessionImpl
java.lang.Object
org.hibernate.impl.AbstractSessionImpl
org.hibernate.impl.SessionImpl
- All Implemented Interfaces:
Serializable,Session,LobCreationContext,SessionImplementor,EventSource,JDBCContext.Context,Session,TransactionFactory.Context
public final class SessionImpl
extends AbstractSessionImpl
implements EventSource, Session, JDBCContext.Context, LobCreationContext
Concrete implementation of a Session, and also the central, organizing component
of Hibernate's internal implementation. As such, this class exposes two interfaces;
Session itself, to the application, and SessionImplementor, to other components
of Hibernate. This class is not threadsafe.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.hibernate.engine.jdbc.LobCreationContext
LobCreationContext.CallbackNested classes/interfaces inherited from interface org.hibernate.Session
Session.LockRequest -
Field Summary
Fields inherited from class org.hibernate.impl.AbstractSessionImpl
factory -
Method Summary
Modifier and TypeMethodDescriptionvoidafterOperation(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 processingvoidvoidWe cannot rely upon this method being called! It is only called if we are using Hibernate Transaction API.voidafterTransactionCompletion(boolean success, Transaction tx) Notify the session that the transaction completed, so we no longer own the old locks.voidapplyNonFlushedChanges(NonFlushedChanges nonFlushedChanges) Apply non-flushed changes from a different session to this session.protected booleanautoFlushIfRequired(Set querySpaces) detect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flushvoidNotify the session that the transaction is about to completeBegin a unit of work and return the associated Transaction object.bestGuessEntityName(Object object) The best guess entity name for an entity not in an associationbuildLockRequest(LockOptions lockOptions) Build a LockRequest that specifies the LockMode, pessimistic lock timeout and lock scope.voidCancel the execution of the current query.voidclear()Completely clear the session.close()End the session by releasing the JDBC connection and cleaning up.Get the JDBC connection of this Session.
If the session is using aggressive collection release (as in a CMT environment), it is the application's responsibility to close the connection returned by this call.booleanCheck if this instance is associated with this Session.createCriteria(Class persistentClass) Create a new Criteria instance, for the given entity class, or a superclass of an entity class.createCriteria(Class persistentClass, String alias) Create a new Criteria instance, for the given entity class, or a superclass of an entity class, with the given alias.createCriteria(String entityName) Create a new Criteria instance, for the given entity name.createCriteria(String entityName, String alias) Create a new Criteria instance, for the given entity name, with the given alias.createFilter(Object collection, String queryString) Create a new instance of Query for the given collection and filter string.createQuery(String queryString) Create a new instance of Query for the given HQL query string.createSQLQuery(String sql) Create a new instance of SQLQuery for the given SQL query string.createSQLQuery(String sql, String[] returnAliases, Class[] returnClasses) Create a new instance of Query for the given SQL string.createSQLQuery(String sql, String returnAlias, Class returnClass) Create a new instance of Query for the given SQL string.voidDelete a persistent objectintDelete all objects returned by the query.voidDelete a persistent object (by explicit entity name)intDelete all objects returned by the query.voidDelete a persistent objectintDelete all objects returned by the query.voiddisableFetchProfile(String name) Disable a particular fetch profile on this session.voiddisableFilter(String filterName) Disable the named filter for the current session.Disconnect the Session from the current JDBC connection.voidController for allowing users to perform JDBC related work using the Connection managed by this Session.voidenableFetchProfile(String name) Enable a particular fetch profile on this session.enableFilter(String filterName) Enable the named filter for this current session.voidremove any hard references to the entity that are held by the infrastructure (references held by application or other persistant instances are okay)execute(LobCreationContext.Callback callback) Execute the given callback, making sure it has access to a viable JDBCConnection.intexecuteNativeUpdate(NativeSQLQuerySpecification nativeQuerySpecification, QueryParameters queryParameters) Execute a native SQL update or delete queryintexecuteUpdate(String query, QueryParameters queryParameters) Execute a HQL update or delete queryApply a filter to a persistent collection.Apply a filter to a persistent collection.Apply a filter to a persistent collection.Retrieve a list of persistent objects using a hibernate queryExecute a query with bind parameters, binding an array of values to "?" parameters in the query string.Execute a query with bind parameters, binding a value to a "?" parameter in the query string.voidflush()Force this session to flush.voidforceFlush(EntityEntry entityEntry) Force an immediate flushget(Class 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.get(Class 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.get(Class 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.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.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.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.Get the ActionQueue for this sessionGet the prepared statement Batcher for this sessionGet the current cache mode.getContextEntityIdentifier(Object object) Get the id value for an object that is actually associated with the session.getCurrentLockMode(Object object) Determine the current lock mode of the given object.intgetEnabledFilter(String filterName) Retrieve a currently enabled filter by name.Return the currently enabled filters.Retrieve the entity mode in effect for this session.getEntityName(Object object) Return the entity name for a persistent entitygetEntityPersister(String entityName, Object object) Get the EntityPersister for any instanceGet the entity instance associated with the given Key, calling the Interceptor if necessaryGet the internal fetch profile currently associated with this session.getFilterParameterType(String filterParameterName) Retreive the type for a given filter parrameter.getFilterParameterValue(String filterParameterName) Retreive the currently set value for a filter parameter.Get the current flush mode for this session.getIdentifier(Object object) Return the identifier value of the given entity as associated with this session.Retrieves the interceptor currently in use by this event source.Retrieves the configured event listeners from this event source.Get the load query influencers associated with this session.Retrieve this session's helper/delegate for creating LOB instances.getNamedQuery(String queryName) Get a Query instance for a named query or named native SQL queryReturn changes to this session and its child sessions that have not been flushed yet.Get the persistence context for this sessiongetSession(EntityMode entityMode) Starts a new Session with the given entity mode in effect.Get the session factory which created this session.Get the statistics for this session.longSystem time before the start of the transactionGet the Transaction instance associated with this session.Convenience access to theTypeHelperassociated with this session'sSessionFactory.guessEntityName(Object object) The guessed entity name for an entity not in an associationimmediateLoad(String entityName, Serializable id) Load the data for the object with the specified id into a newly created object.voidinitializeCollection(PersistentCollection collection, boolean writing) Initialize the collection (if not already initialized)instantiate(String entityName, Serializable id) Instantiate the entity class, initializing with the given identifierinstantiate(EntityPersister persister, Serializable id) give the interceptor an opportunity to override the default instantiationinternalLoad(String entityName, Serializable id, boolean eager, boolean nullable) Load an instance without checking if it was deleted.booleanbooleanCheck if the session is currently connected.booleanWill entities and proxies that are loaded into this session be made read-only by default? To determine the read-only/modifiable setting for a particular entity or proxy:booleanisDirty()Does this session contain any changes which must be synchronized with the database? In other words, would any DML operations be executed if we flushed this session?booleanbooleanisFetchProfileEnabled(String name) Is a particular fetch profile enabled on this session?booleanbooleanbooleanisOpen()Check if the session is still open.booleanisReadOnly(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:booleanDoes this Session have an active Hibernate transaction or is there a JTA transaction in progress?Execute a query and return the results in an iterator.Execute a query and return the results in an iterator.Execute a query and return the results in an iterator.iterate(String query, QueryParameters queryParameters) Execute an iterate() queryiterateFilter(Object collection, String filter, QueryParameters queryParameters) Iterate a filterlist(String query, QueryParameters queryParameters) Execute a find() querylist(CriteriaImpl criteria) Execute a criteria querylistCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) Execute an SQL QuerylistFilter(Object collection, String filter, QueryParameters queryParameters) Execute a filterload(Class entityClass, Serializable id) Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.load(Class 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.load(Class 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.voidload(Object object, Serializable id) Read the persistent state associated with the given identifier into the given transient instance.load(String entityName, Serializable id) Return the persistent instance of the given entity class with the given identifier, assuming that the instance exists.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.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.voidObtain the specified lock level upon the given object.voidObtain the specified lock level upon the given object.voidvoidCopy the state of the given object onto the persistent object with the same identifier.Copy the state of the given object onto the persistent object with the same identifier.voidCascade merge an entity instancevoidMake a transient instance persistent.voidMake a transient instance persistent.voidCascade persist an entity instancevoidpersistOnFlush(Object object) voidpersistOnFlush(String entityName, Object object) voidpersistOnFlush(String entityName, Object object, Map copiedAlready) Cascade persist an entity instance during the flush processvoidObtain a new JDBC connection.voidreconnect(Connection conn) Reconnect to the given JDBC connection.voidRe-read the state of the given instance from the underlying database.voidCascade refesh an entity instancevoidRe-read the state of the given instance from the underlying database, with the given LockMode.voidrefresh(Object object, LockOptions lockOptions) Re-read the state of the given instance from the underlying database, with the given LockMode.voidreplicate(Object obj, ReplicationMode replicationMode) Persist the state of the given detached instance, reusing the current identifier value.voidreplicate(String entityName, Object obj, ReplicationMode replicationMode) Persist the state of the given detached instance, reusing the current identifier value.Persist the given transient instance, first assigning a generated identifier.voidsave(Object obj, Serializable id) Persist the given transient instance, using the given identifier.Persist the given transient instance, first assigning a generated identifier.voidsave(String entityName, Object object, Serializable id) Persist the given transient instance, using the given identifier.voidsaveOrUpdate(Object object) EitherSession.save(Object)orSession.update(Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking).voidsaveOrUpdate(String entityName, Object obj) 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).saveOrUpdateCopy(Object object) Copy the state of the given object onto the persistent object with the same identifier.saveOrUpdateCopy(Object object, Serializable id) Copy the state of the given object onto the persistent object with the given identifier.saveOrUpdateCopy(String entityName, Object object) Copy the state of the given object onto the persistent object with the same identifier.saveOrUpdateCopy(String entityName, Object object, Serializable id) Copy the state of the given object onto the persistent object with the given identifier.voidsaveOrUpdateCopy(String entityName, Object object, Map copiedAlready) Cascade copy an entity instancescroll(String query, QueryParameters queryParameters) Execute a scroll() queryscroll(CriteriaImpl criteria, ScrollMode scrollMode) Execute a criteria queryscrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) Execute an SQL QueryvoidsetAutoClear(boolean enabled) Enable/disable automatic cache clearing from after transaction completion (for EJB3)voidsetCacheMode(CacheMode cacheMode) Set the cache mode.voidsetDefaultReadOnly(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.voidsetFetchProfile(String fetchProfile) Set the current internal fetch profile for this session.voidsetFlushMode(FlushMode flushMode) Set the flush mode for this session.voidsetReadOnly(Object entity, boolean readOnly) Set an unmodified persistent object to read-only mode, or a read-only object to modifiable mode.booleantoString()voidUpdate the persistent instance with the identifier of the given detached instance.voidupdate(Object obj, Serializable id) Update the persistent state associated with the given identifier.voidUpdate the persistent instance with the identifier of the given detached instance.voidupdate(String entityName, Object object, Serializable id) Update the persistent state associated with the given identifier.Methods inherited from class org.hibernate.impl.AbstractSessionImpl
errorIfClosed, getFactory, getHQLQueryPlan, getNamedSQLQuery, getNativeSQLQueryPlan, isClosed, list, scroll, setClosedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.hibernate.engine.SessionImplementor
getFactory, getNamedSQLQuery, isClosed, list, scrollMethods inherited from interface org.hibernate.transaction.TransactionFactory.Context
getFactory, isClosed
-
Method Details
-
getSession
Description copied from interface:SessionStarts a new Session with the given entity mode in effect. This secondary Session inherits the connection, transaction, and other context information from the primary Session. It doesn't need to be flushed or closed by the developer.- Specified by:
getSessionin interfaceSession- Parameters:
entityMode- The entity mode to use for the new session.- Returns:
- The new session
-
clear
public void clear()Description copied from interface:SessionCompletely clear the session. Evict all loaded instances and cancel all pending saves, updates and deletions. Do not close open iterators or instances of ScrollableResults. -
getBatcher
Description copied from interface:SessionImplementorGet the prepared statement Batcher for this session- Specified by:
getBatcherin interfaceSessionImplementor
-
getTimestamp
public long getTimestamp()Description copied from interface:SessionImplementorSystem time before the start of the transaction- Specified by:
getTimestampin interfaceSessionImplementor
-
close
Description copied from interface:SessionEnd the session by releasing the JDBC connection and cleaning up. It is not strictly necessary to close the session but you must at leastSession.disconnect()it.- Specified by:
closein interfaceSession- Returns:
- the connection provided by the application or null.
- Throws:
HibernateException- Indicates problems cleaning up.
-
getConnectionReleaseMode
- Specified by:
getConnectionReleaseModein interfaceJDBCContext.Context
-
isAutoCloseSessionEnabled
public boolean isAutoCloseSessionEnabled()- Specified by:
isAutoCloseSessionEnabledin interfaceJDBCContext.Context
-
isOpen
public boolean isOpen()Description copied from interface:SessionCheck if the session is still open.- Specified by:
isOpenin interfaceSession- Specified by:
isOpenin interfaceSessionImplementor- Returns:
- boolean
-
isFlushModeNever
public boolean isFlushModeNever()- Specified by:
isFlushModeNeverin interfaceTransactionFactory.Context
-
isFlushBeforeCompletionEnabled
public boolean isFlushBeforeCompletionEnabled()- Specified by:
isFlushBeforeCompletionEnabledin interfaceTransactionFactory.Context
-
managedFlush
public void managedFlush()- Specified by:
managedFlushin interfaceTransactionFactory.Context
-
getNonFlushedChanges
Return changes to this session and its child sessions that have not been flushed yet.- Specified by:
getNonFlushedChangesin interfaceSessionImplementor- Returns:
- The non-flushed changes.
- Throws:
HibernateException
-
applyNonFlushedChanges
Apply non-flushed changes from a different session to this session. It is assumed that this SessionImpl is "clean" (e.g., has no non-flushed changes, no cached entities, no cached collections, no queued actions). The specified NonFlushedChanges object cannot be bound to any session.- Specified by:
applyNonFlushedChangesin interfaceSessionImplementor- Parameters:
nonFlushedChanges- the non-flushed changes- Throws:
HibernateException
-
shouldAutoClose
public boolean shouldAutoClose()- Specified by:
shouldAutoClosein interfaceTransactionFactory.Context
-
managedClose
public void managedClose()- Specified by:
managedClosein interfaceTransactionFactory.Context
-
connection
Description copied from interface:SessionGet the JDBC connection of this Session.
If the session is using aggressive collection release (as in a CMT environment), it is the application's responsibility to close the connection returned by this call. Otherwise, the application should not close the connection.- Specified by:
connectionin interfaceSession- Specified by:
connectionin interfaceSessionImplementor- Returns:
- the JDBC connection in use by the Session
- Throws:
HibernateException- if the Session is disconnected
-
isConnected
public boolean isConnected()Description copied from interface:SessionCheck if the session is currently connected.- Specified by:
isConnectedin interfaceSession- Specified by:
isConnectedin interfaceSessionImplementor- Returns:
- boolean
-
isTransactionInProgress
public boolean isTransactionInProgress()Description copied from interface:SessionImplementorDoes this Session have an active Hibernate transaction or is there a JTA transaction in progress?- Specified by:
isTransactionInProgressin interfaceSessionImplementor
-
disconnect
Description copied from interface:SessionDisconnect the Session from the current JDBC connection. If the connection was obtained by Hibernate close it and return it to the connection pool; otherwise, return it to the application. This is used by applications which supply JDBC connections to Hibernate and which require long-sessions (or long-conversations) Note that disconnect() called on a session where the connection was retrieved by Hibernate through its configuredConnectionProviderhas no effect, providedConnectionReleaseMode.ON_CLOSEis not in effect.- Specified by:
disconnectin interfaceSession- Returns:
- the application-supplied connection or null
- Throws:
HibernateException- See Also:
-
reconnect
Description copied from interface:SessionObtain a new JDBC connection. This is used by applications which require long transactions and do not supply connections to the session.- Specified by:
reconnectin interfaceSession- Throws:
HibernateException- See Also:
-
reconnect
Description copied from interface:SessionReconnect to the given JDBC connection. This is used by applications which require long transactions and use application-supplied connections.- Specified by:
reconnectin interfaceSession- Parameters:
conn- a JDBC connection- Throws:
HibernateException- See Also:
-
beforeTransactionCompletion
Description copied from interface:SessionImplementorNotify the session that the transaction is about to complete- Specified by:
beforeTransactionCompletionin interfaceJDBCContext.Context- Specified by:
beforeTransactionCompletionin interfaceSessionImplementor
-
setAutoClear
public void setAutoClear(boolean enabled) Description copied from interface:SessionImplementorEnable/disable automatic cache clearing from after transaction completion (for EJB3)- Specified by:
setAutoClearin interfaceSessionImplementor
-
afterOperation
public 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 -
afterTransactionCompletion
Description copied from interface:SessionImplementorNotify the session that the transaction completed, so we no longer own the old locks. (Also we should release cache softlocks.) May be called multiple times during the transaction completion process. Also called after an autocommit, in which case the second argument is null.- Specified by:
afterTransactionCompletionin interfaceJDBCContext.Context- Specified by:
afterTransactionCompletionin interfaceSessionImplementor
-
getCurrentLockMode
Description copied from interface:SessionDetermine the current lock mode of the given object.- Specified by:
getCurrentLockModein interfaceSession- Parameters:
object- a persistent instance- Returns:
- the current lock mode
- Throws:
HibernateException
-
getEntityUsingInterceptor
Description copied from interface:SessionImplementorGet the entity instance associated with the given Key, calling the Interceptor if necessary- Specified by:
getEntityUsingInterceptorin interfaceSessionImplementor- Throws:
HibernateException
-
saveOrUpdate
Description copied from interface:SessionEitherSession.save(Object)orSession.update(Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking). This operation cascades to associated instances if the association is mapped with cascade="save-update".- Specified by:
saveOrUpdatein interfaceSession- Parameters:
object- a transient or detached instance containing new or updated state- Throws:
HibernateException- See Also:
-
saveOrUpdate
Description copied from interface:SessionEitherSession.save(String, Object)orSession.update(String, Object)the given instance, depending upon resolution of the unsaved-value checks (see the manual for discussion of unsaved-value checking). This operation cascades to associated instances if the association is mapped with cascade="save-update".- Specified by:
saveOrUpdatein interfaceSession- Parameters:
obj- a transient or detached instance containing new or updated state- Throws:
HibernateException- See Also:
-
save
Description copied from interface:SessionPersist the given transient instance, using the given identifier. This operation cascades to associated instances if the association is mapped with cascade="save-update".- Specified by:
savein interfaceSession- Parameters:
obj- a transient instance of a persistent classid- an unused valid identifier- Throws:
HibernateException
-
save
Description copied from interface:SessionPersist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if the assigned generator is used.) This operation cascades to associated instances if the association is mapped with cascade="save-update".- Specified by:
savein interfaceSession- Parameters:
obj- a transient instance of a persistent class- Returns:
- the generated identifier
- Throws:
HibernateException
-
save
Description copied from interface:SessionPersist the given transient instance, first assigning a generated identifier. (Or using the current value of the identifier property if the assigned generator is used.) This operation cascades to associated instances if the association is mapped with cascade="save-update".- Specified by:
savein interfaceSession- Parameters:
object- a transient instance of a persistent class- Returns:
- the generated identifier
- Throws:
HibernateException
-
save
Description copied from interface:SessionPersist the given transient instance, using the given identifier. This operation cascades to associated instances if the association is mapped with cascade="save-update".- Specified by:
savein interfaceSession- Parameters:
object- a transient instance of a persistent classid- an unused valid identifier- Throws:
HibernateException
-
update
Description copied from interface:SessionUpdate the persistent instance with the identifier of the given detached instance. If there is a persistent instance with the same identifier, an exception is thrown. This operation cascades to associated instances if the association is mapped with cascade="save-update".- Specified by:
updatein interfaceSession- Parameters:
obj- a detached instance containing updated state- Throws:
HibernateException
-
update
Description copied from interface:SessionUpdate the persistent state associated with the given identifier. An exception is thrown if there is a persistent instance with the same identifier in the current session. This operation cascades to associated instances if the association is mapped with cascade="save-update".- Specified by:
updatein interfaceSession- Parameters:
obj- a detached instance containing updated stateid- identifier of persistent instance- Throws:
HibernateException
-
update
Description copied from interface:SessionUpdate the persistent instance with the identifier of the given detached instance. If there is a persistent instance with the same identifier, an exception is thrown. This operation cascades to associated instances if the association is mapped with cascade="save-update".- Specified by:
updatein interfaceSession- Parameters:
object- a detached instance containing updated state- Throws:
HibernateException
-
update
Description copied from interface:SessionUpdate the persistent state associated with the given identifier. An exception is thrown if there is a persistent instance with the same identifier in the current session. This operation cascades to associated instances if the association is mapped with cascade="save-update".- Specified by:
updatein interfaceSession- Parameters:
object- a detached instance containing updated stateid- identifier of persistent instance- Throws:
HibernateException
-
lock
Description copied from interface:SessionObtain the specified lock level upon the given object. This may be used to perform a version check (LockMode.OPTIMISTIC), to upgrade to a pessimistic lock (LockMode.PESSIMISTIC_WRITE), or to simply reassociate a transient instance with a session (LockMode.NONE). This operation cascades to associated instances if the association is mapped with cascade="lock".- Specified by:
lockin interfaceSession- Parameters:
object- a persistent or transient instancelockMode- the lock level- Throws:
HibernateException
-
buildLockRequest
Description copied from interface:SessionBuild a LockRequest that specifies the LockMode, pessimistic lock timeout and lock scope. timeout and scope is ignored for optimistic locking. After building the LockRequest, call LockRequest.lock to perform the requested locking. Use: session.buildLockRequest(). setLockMode(LockMode.PESSIMISTIC_WRITE).setTimeOut(1000 * 60).lock(entity);- Specified by:
buildLockRequestin interfaceSession- Parameters:
lockOptions- contains the lock level- Returns:
- a lockRequest that can be used to lock the passed object.
-
lock
Description copied from interface:SessionObtain the specified lock level upon the given object. This may be used to perform a version check (LockMode.READ), to upgrade to a pessimistic lock (LockMode.PESSIMISTIC_WRITE), or to simply reassociate a transient instance with a session (LockMode.NONE). This operation cascades to associated instances if the association is mapped with cascade="lock".- Specified by:
lockin interfaceSession- Parameters:
object- a persistent or transient instancelockMode- the lock level- Throws:
HibernateException
-
persist
Description copied from interface:SessionMake a transient instance persistent. This operation cascades to associated instances if the association is mapped with cascade="persist".
The semantics of this method are defined by JSR-220.- Specified by:
persistin interfaceSession- Parameters:
object- a transient instance to be made persistent- Throws:
HibernateException
-
persist
Description copied from interface:SessionMake a transient instance persistent. This operation cascades to associated instances if the association is mapped with cascade="persist".
The semantics of this method are defined by JSR-220.- Specified by:
persistin interfaceSession- Parameters:
object- a transient instance to be made persistent- Throws:
HibernateException
-
persist
Description copied from interface:EventSourceCascade persist an entity instance- Specified by:
persistin interfaceEventSource- Throws:
HibernateException
-
persistOnFlush
- Throws:
HibernateException
-
persistOnFlush
- Throws:
HibernateException
-
persistOnFlush
public void persistOnFlush(String entityName, Object object, Map copiedAlready) throws HibernateException Description copied from interface:EventSourceCascade persist an entity instance during the flush process- Specified by:
persistOnFlushin interfaceEventSource- Throws:
HibernateException
-
merge
Description copied from interface:SessionCopy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved, save a copy of and return it as a newly persistent instance. The given instance does not become associated with the session. This operation cascades to associated instances if the association is mapped with cascade="merge".
The semantics of this method are defined by JSR-220.- Specified by:
mergein interfaceSession- Parameters:
object- a detached instance with state to be copied- Returns:
- an updated persistent instance
- Throws:
HibernateException
-
merge
Description copied from interface:SessionCopy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved, save a copy of and return it as a newly persistent instance. The given instance does not become associated with the session. This operation cascades to associated instances if the association is mapped with cascade="merge".
The semantics of this method are defined by JSR-220.- Specified by:
mergein interfaceSession- Parameters:
object- a detached instance with state to be copied- Returns:
- an updated persistent instance
- Throws:
HibernateException
-
merge
Description copied from interface:EventSourceCascade merge an entity instance- Specified by:
mergein interfaceEventSource- Throws:
HibernateException
-
saveOrUpdateCopy
Description copied from interface:SessionCopy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved or does not exist in the database, save it and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.- Specified by:
saveOrUpdateCopyin interfaceSession- Parameters:
object- a transient instance with state to be copied- Returns:
- an updated persistent instance
- Throws:
HibernateException
-
saveOrUpdateCopy
Description copied from interface:SessionCopy the state of the given object onto the persistent object with the same identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If the given instance is unsaved or does not exist in the database, save it and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.- Specified by:
saveOrUpdateCopyin interfaceSession- Parameters:
object- a transient instance with state to be copied- Returns:
- an updated persistent instance
- Throws:
HibernateException
-
saveOrUpdateCopy
public Object saveOrUpdateCopy(String entityName, Object object, Serializable id) throws HibernateException Description copied from interface:SessionCopy the state of the given object onto the persistent object with the given identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If there is no database row with the given identifier, save the given instance and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.- Specified by:
saveOrUpdateCopyin interfaceSession- Parameters:
object- a persistent or transient instance with state to be copiedid- the identifier of the instance to copy to- Returns:
- an updated persistent instance
- Throws:
HibernateException
-
saveOrUpdateCopy
Description copied from interface:SessionCopy the state of the given object onto the persistent object with the given identifier. If there is no persistent instance currently associated with the session, it will be loaded. Return the persistent instance. If there is no database row with the given identifier, save the given instance and return it as a newly persistent instance. Otherwise, the given instance does not become associated with the session.- Specified by:
saveOrUpdateCopyin interfaceSession- Parameters:
object- a persistent or transient instance with state to be copiedid- the identifier of the instance to copy to- Returns:
- an updated persistent instance
- Throws:
HibernateException
-
saveOrUpdateCopy
public void saveOrUpdateCopy(String entityName, Object object, Map copiedAlready) throws HibernateException Description copied from interface:EventSourceCascade copy an entity instance- Specified by:
saveOrUpdateCopyin interfaceEventSource- Throws:
HibernateException
-
delete
Delete a persistent object- Specified by:
deletein interfaceSession- Parameters:
object- the instance to be removed- Throws:
HibernateException
-
delete
Delete a persistent object (by explicit entity name)- Specified by:
deletein interfaceSession- Parameters:
entityName- The entity name for the instance to be removed.object- the instance to be removed- Throws:
HibernateException
-
delete
public void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, Set transientEntities) throws HibernateException Delete a persistent object- Specified by:
deletein interfaceEventSource- Throws:
HibernateException
-
load
Description copied from interface:SessionRead the persistent state associated with the given identifier into the given transient instance.- Specified by:
loadin interfaceSession- Parameters:
object- an "empty" instance of the persistent classid- a valid identifier of an existing persistent instance of the class- Throws:
HibernateException
-
load
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, assuming that the instance exists. This method might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed.
You should not use this method to determine if an instance exists (use get() instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.- Specified by:
loadin interfaceSession- Parameters:
entityClass- a persistent classid- a valid identifier of an existing persistent instance of the class- Returns:
- the persistent instance or proxy
- Throws:
HibernateException
-
load
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, assuming that the instance exists. This method might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed.
You should not use this method to determine if an instance exists (use get() instead). Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.- Specified by:
loadin interfaceSession- Parameters:
entityName- a persistent classid- a valid identifier of an existing persistent instance of the class- Returns:
- the persistent instance or proxy
- Throws:
HibernateException
-
get
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.)- Specified by:
getin interfaceSession- Parameters:
entityClass- a persistent classid- an identifier- Returns:
- a persistent instance or null
- Throws:
HibernateException
-
get
Description copied from interface:SessionReturn the persistent instance of the given named entity with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.)- Specified by:
getin interfaceSession- Parameters:
entityName- the entity nameid- an identifier- Returns:
- a persistent instance or null
- Throws:
HibernateException
-
immediateLoad
Load the data for the object with the specified id into a newly created object. This is only called when lazily initializing a proxy. Do NOT return a proxy.- Specified by:
immediateLoadin interfaceSessionImplementor- Throws:
HibernateException
-
internalLoad
public Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) throws HibernateException Description copied from interface:SessionImplementorLoad an instance without checking if it was deleted. When nullable is disabled this method may create a new proxy or return an existing proxy; if it does not exist, throw an exception. When nullable is enabled, the method does not create new proxies (but might return an existing proxy); if it does not exist, return null. When eager is enabled, the object is eagerly fetched- Specified by:
internalLoadin interfaceSessionImplementor- Throws:
HibernateException
-
load
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.- Specified by:
loadin interfaceSession- Parameters:
entityClass- a persistent classid- a valid identifier of an existing persistent instance of the classlockMode- the lock level- Returns:
- the persistent instance or proxy
- Throws:
HibernateException
-
load
public Object load(Class entityClass, Serializable id, LockOptions lockOptions) throws HibernateException Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.- Specified by:
loadin interfaceSession- Parameters:
entityClass- a persistent classid- a valid identifier of an existing persistent instance of the classlockOptions- contains the lock level- Returns:
- the persistent instance or proxy
- Throws:
HibernateException
-
load
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.- Specified by:
loadin interfaceSession- Parameters:
entityName- a persistent classid- a valid identifier of an existing persistent instance of the classlockMode- the lock level- Returns:
- the persistent instance or proxy
- Throws:
HibernateException
-
load
public Object load(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.- Specified by:
loadin interfaceSession- Parameters:
entityName- a persistent classid- a valid identifier of an existing persistent instance of the classlockOptions- contains the lock level- Returns:
- the persistent instance or proxy
- Throws:
HibernateException
-
get
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.) Obtain the specified lock mode if the instance exists.- Specified by:
getin interfaceSession- Parameters:
entityClass- a persistent classid- an identifierlockMode- the lock mode- Returns:
- a persistent instance or null
- Throws:
HibernateException
-
get
public Object get(Class entityClass, Serializable id, LockOptions lockOptions) throws HibernateException Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.) Obtain the specified lock mode if the instance exists.- Specified by:
getin interfaceSession- Parameters:
entityClass- a persistent classid- an identifierlockOptions- the lock mode- Returns:
- a persistent instance or null
- Throws:
HibernateException
-
get
Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.) Obtain the specified lock mode if the instance exists.- Specified by:
getin interfaceSession- Parameters:
entityName- the entity nameid- an identifierlockMode- the lock mode- Returns:
- a persistent instance or null
- Throws:
HibernateException
-
get
public Object get(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException Description copied from interface:SessionReturn the persistent instance of the given entity class with the given identifier, or null if there is no such persistent instance. (If the instance is already associated with the session, return that instance. This method never returns an uninitialized instance.) Obtain the specified lock mode if the instance exists.- Specified by:
getin interfaceSession- Parameters:
entityName- the entity nameid- an identifierlockOptions- contains the lock mode- Returns:
- a persistent instance or null
- Throws:
HibernateException
-
refresh
Description copied from interface:SessionRe-read the state of the given instance from the underlying database. It is inadvisable to use this to implement long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances. For example- where a database trigger alters the object state upon insert or update
- after executing direct SQL (eg. a mass update) in the same session
- after inserting a Blob or Clob
- Specified by:
refreshin interfaceSession- Parameters:
object- a persistent or detached instance- Throws:
HibernateException
-
refresh
Description copied from interface:SessionRe-read the state of the given instance from the underlying database, with the given LockMode. It is inadvisable to use this to implement long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances.- Specified by:
refreshin interfaceSession- Parameters:
object- a persistent or detached instancelockMode- the lock mode to use- Throws:
HibernateException
-
refresh
Description copied from interface:SessionRe-read the state of the given instance from the underlying database, with the given LockMode. It is inadvisable to use this to implement long-running sessions that span many business tasks. This method is, however, useful in certain special circumstances.- Specified by:
refreshin interfaceSession- Parameters:
object- a persistent or detached instancelockOptions- contains the lock mode to use- Throws:
HibernateException
-
refresh
Description copied from interface:EventSourceCascade refesh an entity instance- Specified by:
refreshin interfaceEventSource- Throws:
HibernateException
-
replicate
Description copied from interface:SessionPersist the state of the given detached instance, reusing the current identifier value. This operation cascades to associated instances if the association is mapped with cascade="replicate".- Specified by:
replicatein interfaceSession- Parameters:
obj- a detached instance of a persistent class- Throws:
HibernateException
-
replicate
public void replicate(String entityName, Object obj, ReplicationMode replicationMode) throws HibernateException Description copied from interface:SessionPersist the state of the given detached instance, reusing the current identifier value. This operation cascades to associated instances if the association is mapped with cascade="replicate".- Specified by:
replicatein interfaceSession- Parameters:
obj- a detached instance of a persistent class- Throws:
HibernateException
-
evict
remove any hard references to the entity that are held by the infrastructure (references held by application or other persistant instances are okay)- Specified by:
evictin interfaceSession- Parameters:
object- a persistent instance- Throws:
HibernateException
-
autoFlushIfRequired
detect in-memory changes, determine if the changes are to tables named in the query and, if so, complete execution the flush- Throws:
HibernateException
-
isDirty
Description copied from interface:SessionDoes this session contain any changes which must be synchronized with the database? In other words, would any DML operations be executed if we flushed this session?- Specified by:
isDirtyin interfaceSession- Returns:
- True if the session contains pending changes; false otherwise.
- Throws:
HibernateException- could not perform dirtying checking
-
flush
Description copied from interface:SessionForce this session to flush. Must be called at the end of a unit of work, before committing the transaction and closing the session (depending onflush-mode,Transaction.commit()calls this method). Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory.- Specified by:
flushin interfaceSession- Specified by:
flushin interfaceSessionImplementor- Throws:
HibernateException- Indicates problems flushing the session or talking to the database.
-
forceFlush
Description copied from interface:EventSourceForce an immediate flush- Specified by:
forceFlushin interfaceEventSource- Throws:
HibernateException
-
find
Retrieve a list of persistent objects using a hibernate query- Specified by:
findin interfaceSession- Parameters:
query- a query expressed in Hibernate's query language- Returns:
- a distinct list of instances (or arrays of instances)
- Throws:
HibernateException
-
find
Description copied from interface:SessionExecute a query with bind parameters, binding a value to a "?" parameter in the query string.- Specified by:
findin interfaceSession- Parameters:
query- the query stringvalue- a value to be bound to a "?" placeholder (JDBC IN parameter).type- the Hibernate type of the value- Returns:
- a distinct list of instances (or arrays of instances)
- Throws:
HibernateException- See Also:
-
find
Description copied from interface:SessionExecute a query with bind parameters, binding an array of values to "?" parameters in the query string.- Specified by:
findin interfaceSession- Parameters:
query- the query stringvalues- an array of values to be bound to the "?" placeholders (JDBC IN parameters).types- an array of Hibernate types of the values- Returns:
- a distinct list of instances
- Throws:
HibernateException- See Also:
-
list
Description copied from interface:SessionImplementorExecute a find() query- Specified by:
listin interfaceSessionImplementor- Throws:
HibernateException
-
executeUpdate
Description copied from interface:SessionImplementorExecute a HQL update or delete query- Specified by:
executeUpdatein interfaceSessionImplementor- Throws:
HibernateException
-
executeNativeUpdate
public int executeNativeUpdate(NativeSQLQuerySpecification nativeQuerySpecification, QueryParameters queryParameters) throws HibernateException Description copied from interface:SessionImplementorExecute a native SQL update or delete query- Specified by:
executeNativeUpdatein interfaceSessionImplementor- Throws:
HibernateException
-
iterate
Description copied from interface:SessionExecute a query and return the results in an iterator. If the query has multiple return values, values will be returned in an array of type Object[].
Entities returned as results are initialized on demand. The first SQL query returns identifiers only. So iterate() is usually a less efficient way to retrieve objects than find().- Specified by:
iteratein interfaceSession- Parameters:
query- the query string- Returns:
- an iterator
- Throws:
HibernateException
-
iterate
Description copied from interface:SessionExecute a query and return the results in an iterator. Write the given value to "?" in the query string. If the query has multiple return values, values will be returned in an array of type Object[].
Entities returned as results are initialized on demand. The first SQL query returns identifiers only. So iterate() is usually a less efficient way to retrieve objects than find().- Specified by:
iteratein interfaceSession- Parameters:
query- the query stringvalue- a value to be witten to a "?" placeholder in the query stringtype- the hibernate type of value- Returns:
- an iterator
- Throws:
HibernateException
-
iterate
Description copied from interface:SessionExecute a query and return the results in an iterator. Write the given values to "?" in the query string. If the query has multiple return values, values will be returned in an array of type Object[].
Entities returned as results are initialized on demand. The first SQL query returns identifiers only. So iterate() is usually a less efficient way to retrieve objects than find().- Specified by:
iteratein interfaceSession- Parameters:
query- the query stringvalues- a list of values to be written to "?" placeholders in the querytypes- a list of Hibernate types of the values- Returns:
- an iterator
- Throws:
HibernateException
-
iterate
Description copied from interface:SessionImplementorExecute an iterate() query- Specified by:
iteratein interfaceSessionImplementor- Throws:
HibernateException
-
scroll
public ScrollableResults scroll(String query, QueryParameters queryParameters) throws HibernateException Description copied from interface:SessionImplementorExecute a scroll() query- Specified by:
scrollin interfaceSessionImplementor- Throws:
HibernateException
-
delete
Description copied from interface:SessionDelete all objects returned by the query. Return the number of objects deleted. Note that this is very different from the delete-statement support added in HQL since 3.1. The functionality here is to actually peform the query and then iterate the results callingSession.delete(Object)individually.- Specified by:
deletein interfaceSession- Parameters:
query- the query string- Returns:
- the number of instances deleted
- Throws:
HibernateException
-
delete
Description copied from interface:SessionDelete all objects returned by the query. Return the number of objects deleted. Note that this is very different from the delete-statement support added in HQL since 3.1. The functionality here is to actually peform the query and then iterate the results callingSession.delete(Object)individually.- Specified by:
deletein interfaceSession- Parameters:
query- the query stringvalue- a value to be witten to a "?" placeholder in the query string.type- the hibernate type of value.- Returns:
- the number of instances deleted
- Throws:
HibernateException
-
delete
Description copied from interface:SessionDelete all objects returned by the query. Return the number of objects deleted. Note that this is very different from the delete-statement support added in HQL since 3.1. The functionality here is to actually peform the query and then iterate the results callingSession.delete(Object)individually.- Specified by:
deletein interfaceSession- Parameters:
query- the query stringvalues- a list of values to be written to "?" placeholders in the query.types- a list of Hibernate types of the values- Returns:
- the number of instances deleted
- Throws:
HibernateException
-
createFilter
Description copied from interface:SessionCreate a new instance of Query for the given collection and filter string.- Specified by:
createFilterin interfaceSession- Parameters:
collection- a persistent collectionqueryString- a Hibernate query- Returns:
- Query
-
getNamedQuery
Description copied from interface:SessionImplementorGet a Query instance for a named query or named native SQL query- Specified by:
getNamedQueryin interfaceSession- Specified by:
getNamedQueryin interfaceSessionImplementor- Overrides:
getNamedQueryin classAbstractSessionImpl- Parameters:
queryName- the name of a query defined externally- Returns:
- Query
- Throws:
MappingException
-
instantiate
Description copied from interface:SessionImplementorInstantiate the entity class, initializing with the given identifier- Specified by:
instantiatein interfaceSessionImplementor- Throws:
HibernateException
-
instantiate
give the interceptor an opportunity to override the default instantiation- Specified by:
instantiatein interfaceEventSource- Throws:
HibernateException
-
getEntityMode
Description copied from interface:SessionRetrieve the entity mode in effect for this session.- Specified by:
getEntityModein interfaceSession- Specified by:
getEntityModein interfaceSessionImplementor- Returns:
- The entity mode for this session.
-
setFlushMode
Description copied from interface:SessionSet the flush mode for this session. The flush mode determines the points at which the session is flushed. Flushing is the process of synchronizing the underlying persistent store with persistable state held in memory. For a logically "read only" session, it is reasonable to set the session's flush mode toFlushMode.MANUALat the start of the session (in order to achieve some extra performance).- Specified by:
setFlushModein interfaceSession- Specified by:
setFlushModein interfaceSessionImplementor- Parameters:
flushMode- the new flush mode- See Also:
-
getFlushMode
Description copied from interface:SessionGet the current flush mode for this session.- Specified by:
getFlushModein interfaceSession- Specified by:
getFlushModein interfaceSessionImplementor- Returns:
- The flush mode
-
getCacheMode
Description copied from interface:SessionGet the current cache mode.- Specified by:
getCacheModein interfaceSession- Specified by:
getCacheModein interfaceSessionImplementor- Returns:
- The current cache mode.
-
setCacheMode
Description copied from interface:SessionSet the cache mode. Cache mode determines the manner in which this session can interact with the second level cache.- Specified by:
setCacheModein interfaceSession- Specified by:
setCacheModein interfaceSessionImplementor- Parameters:
cacheMode- The new cache mode.
-
getTransaction
Description copied from interface:SessionGet the Transaction instance associated with this session. The class of the returned Transaction object is determined by the property hibernate.transaction_factory.- Specified by:
getTransactionin interfaceSession- Returns:
- a Transaction instance
- Throws:
HibernateException- See Also:
-
beginTransaction
Description copied from interface:SessionBegin a unit of work and return the associated Transaction object. If a new underlying transaction is required, begin the transaction. Otherwise continue the new work in the context of the existing underlying transaction. The class of the returned Transaction object is determined by the property hibernate.transaction_factory.- Specified by:
beginTransactionin interfaceSession- Returns:
- a Transaction instance
- Throws:
HibernateException- See Also:
-
afterTransactionBegin
Description copied from interface:JDBCContext.ContextWe cannot rely upon this method being called! It is only called if we are using Hibernate Transaction API.- Specified by:
afterTransactionBeginin interfaceJDBCContext.Context
-
getEntityPersister
Description copied from interface:SessionImplementorGet the EntityPersister for any instance- Specified by:
getEntityPersisterin interfaceSessionImplementor- Parameters:
entityName- optional entity nameobject- the entity instance
-
getIdentifier
Description copied from interface:SessionReturn the identifier value of the given entity as associated with this session. An exception is thrown if the given entity instance is transient or detached in relation to this session.- Specified by:
getIdentifierin interfaceSession- Parameters:
object- a persistent instance- Returns:
- the identifier
- Throws:
HibernateException
-
getContextEntityIdentifier
Get the id value for an object that is actually associated with the session. This is a bit stricter than getEntityIdentifierIfNotUnsaved().- Specified by:
getContextEntityIdentifierin interfaceSessionImplementor
-
filter
Description copied from interface:SessionApply a filter to a persistent collection. A filter is a Hibernate query that may refer to this, the collection element. Filters allow efficient access to very large lazy collections. (Executing the filter does not initialize the collection.)- Specified by:
filterin interfaceSession- Parameters:
collection- a persistent collection to filterfilter- a filter query string- Returns:
- Collection the resulting collection
- Throws:
HibernateException
-
filter
public Collection filter(Object collection, String filter, Object value, Type type) throws HibernateException Description copied from interface:SessionApply a filter to a persistent collection. A filter is a Hibernate query that may refer to this, the collection element.- Specified by:
filterin interfaceSession- Parameters:
collection- a persistent collection to filterfilter- a filter query stringvalue- a value to be witten to a "?" placeholder in the query stringtype- the hibernate type of value- Returns:
- Collection
- Throws:
HibernateException
-
filter
public Collection filter(Object collection, String filter, Object[] values, Type[] types) throws HibernateException Description copied from interface:SessionApply a filter to a persistent collection. Bind the given parameters to "?" placeholders. A filter is a Hibernate query that may refer to this, the collection element.- Specified by:
filterin interfaceSession- Parameters:
collection- a persistent collection to filterfilter- a filter query stringvalues- a list of values to be written to "?" placeholders in the querytypes- a list of Hibernate types of the values- Returns:
- Collection
- Throws:
HibernateException
-
listFilter
public List listFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException Description copied from interface:SessionImplementorExecute a filter- Specified by:
listFilterin interfaceSessionImplementor- Throws:
HibernateException
-
iterateFilter
public Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException Description copied from interface:SessionImplementorIterate a filter- Specified by:
iterateFilterin interfaceSessionImplementor- Throws:
HibernateException
-
createCriteria
Description copied from interface:SessionCreate a new Criteria instance, for the given entity class, or a superclass of an entity class, with the given alias.- Specified by:
createCriteriain interfaceSession- Parameters:
persistentClass- a class, which is persistent, or has persistent subclasses- Returns:
- Criteria
-
createCriteria
Description copied from interface:SessionCreate a new Criteria instance, for the given entity name, with the given alias.- Specified by:
createCriteriain interfaceSession- Parameters:
entityName-- Returns:
- Criteria
-
createCriteria
Description copied from interface:SessionCreate a new Criteria instance, for the given entity class, or a superclass of an entity class.- Specified by:
createCriteriain interfaceSession- Parameters:
persistentClass- a class, which is persistent, or has persistent subclasses- Returns:
- Criteria
-
createCriteria
Description copied from interface:SessionCreate a new Criteria instance, for the given entity name.- Specified by:
createCriteriain interfaceSession- Parameters:
entityName-- Returns:
- Criteria
-
scroll
Description copied from interface:SessionImplementorExecute a criteria query- Specified by:
scrollin interfaceSessionImplementor
-
list
Description copied from interface:SessionImplementorExecute a criteria query- Specified by:
listin interfaceSessionImplementor- Throws:
HibernateException
-
contains
Description copied from interface:SessionCheck if this instance is associated with this Session. -
createQuery
Description copied from interface:SessionCreate a new instance of Query for the given HQL query string.- Specified by:
createQueryin interfaceSession- Overrides:
createQueryin classAbstractSessionImpl- Parameters:
queryString- a HQL query- Returns:
- Query
-
createSQLQuery
Description copied from interface:SessionCreate a new instance of SQLQuery for the given SQL query string.- Specified by:
createSQLQueryin interfaceSession- Overrides:
createSQLQueryin classAbstractSessionImpl- Parameters:
sql- a SQL query- Returns:
- SQLQuery
-
createSQLQuery
Description copied from interface:SessionCreate a new instance of Query for the given SQL string. Returned instances should all beSQLQuery.- Specified by:
createSQLQueryin interfaceSession- Parameters:
sql- a query expressed in SQLreturnAlias- a table alias that appears inside {} in the SQL stringreturnClass- the returned persistent class
-
createSQLQuery
Description copied from interface:SessionCreate a new instance of Query for the given SQL string. Returned instances should all beSQLQuery.- Specified by:
createSQLQueryin interfaceSession- Parameters:
sql- a query expressed in SQLreturnAliases- an array of table aliases that appear inside {} in the SQL stringreturnClasses- the returned persistent classes
-
scrollCustomQuery
public ScrollableResults scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException Description copied from interface:SessionImplementorExecute an SQL Query- Specified by:
scrollCustomQueryin interfaceSessionImplementor- Throws:
HibernateException
-
listCustomQuery
public List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException Description copied from interface:SessionImplementorExecute an SQL Query- Specified by:
listCustomQueryin interfaceSessionImplementor- Throws:
HibernateException
-
getSessionFactory
Description copied from interface:SessionGet the session factory which created this session.- Specified by:
getSessionFactoryin interfaceSession- Returns:
- The session factory.
- See Also:
-
initializeCollection
public void initializeCollection(PersistentCollection collection, boolean writing) throws HibernateException Description copied from interface:SessionImplementorInitialize the collection (if not already initialized)- Specified by:
initializeCollectionin interfaceSessionImplementor- Throws:
HibernateException
-
bestGuessEntityName
Description copied from interface:SessionImplementorThe best guess entity name for an entity not in an association- Specified by:
bestGuessEntityNamein interfaceSessionImplementor
-
getEntityName
Description copied from interface:SessionReturn the entity name for a persistent entity- Specified by:
getEntityNamein interfaceSession- Parameters:
object- a persistent entity- Returns:
- the entity name
-
guessEntityName
Description copied from interface:SessionImplementorThe guessed entity name for an entity not in an association- Specified by:
guessEntityNamein interfaceSessionImplementor- Throws:
HibernateException
-
cancelQuery
Description copied from interface:SessionCancel the execution of the current query. This is the sole method on session which may be safely called from another thread.- Specified by:
cancelQueryin interfaceSession- Throws:
HibernateException- There was a problem canceling the query
-
getInterceptor
Description copied from interface:SessionImplementorRetrieves the interceptor currently in use by this event source.- Specified by:
getInterceptorin interfaceSessionImplementor- Returns:
- The interceptor.
-
getDontFlushFromFind
public int getDontFlushFromFind()- Specified by:
getDontFlushFromFindin interfaceSessionImplementor
-
toString
-
getListeners
Description copied from interface:SessionImplementorRetrieves the configured event listeners from this event source.- Specified by:
getListenersin interfaceSessionImplementor- Returns:
- The configured event listeners.
-
getActionQueue
Description copied from interface:EventSourceGet the ActionQueue for this session- Specified by:
getActionQueuein interfaceEventSource
-
getPersistenceContext
Description copied from interface:SessionImplementorGet the persistence context for this session- Specified by:
getPersistenceContextin interfaceSessionImplementor
-
getStatistics
Description copied from interface:SessionGet the statistics for this session.- Specified by:
getStatisticsin interfaceSession
-
isEventSource
public boolean isEventSource()- Specified by:
isEventSourcein interfaceSessionImplementor
-
isDefaultReadOnly
public 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:- Specified by:
isDefaultReadOnlyin interfaceSession- Returns:
- true, loaded entities/proxies will be made read-only by default; false, loaded entities/proxies will be made modifiable by default.
- See Also:
-
setDefaultReadOnly
public 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. Read-only entities are not dirty-checked and snapshots of persistent state are not maintained. Read-only entities can be modified, but changes are not persisted. When a proxy is initialized, the loaded entity will have the same read-only/modifiable setting as the uninitialized proxy has, regardless of the session's current setting. To change the read-only/modifiable setting for a particular entity or proxy that is already in this session:- Specified by:
setDefaultReadOnlyin interfaceSession- Parameters:
defaultReadOnly- true, the default for loaded entities/proxies is read-only; false, the default for loaded entities/proxies is modifiable- See Also:
-
isReadOnly
Description copied from interface:SessionIs the specified entity or proxy read-only? To get the default read-only/modifiable setting used for entities and proxies that are loaded into the session:- Specified by:
isReadOnlyin interfaceSession- Parameters:
entityOrProxy- an entity or HibernateProxy- Returns:
- true, the entity or proxy is read-only; false, the entity or proxy is modifiable.
- See Also:
-
setReadOnly
Description copied from interface:SessionSet an unmodified persistent object to read-only mode, or a read-only object to modifiable mode. In read-only mode, no snapshot is maintained, the instance is never dirty checked, and changes are not persisted. If the entity or proxy already has the specified read-only/modifiable setting, then this method does nothing. To set the default read-only/modifiable setting used for entities and proxies that are loaded into the session:- Specified by:
setReadOnlyin interfaceSession- Parameters:
entity- an entity or HibernateProxyreadOnly- if true, the entity or proxy is made read-only; if false, the entity or proxy is made modifiable.- See Also:
-
doWork
Description copied from interface:SessionController for allowing users to perform JDBC related work using the Connection managed by this Session.- Specified by:
doWorkin interfaceSession- Parameters:
work- The work to be performed.- Throws:
HibernateException- Generally indicates wrappedSQLException
-
afterScrollOperation
public void afterScrollOperation()- Specified by:
afterScrollOperationin interfaceSessionImplementor
-
getJDBCContext
- Specified by:
getJDBCContextin interfaceSessionImplementor
-
getLoadQueryInfluencers
Description copied from interface:SessionImplementorGet the load query influencers associated with this session.- Specified by:
getLoadQueryInfluencersin interfaceSessionImplementor- Returns:
- the load query influencers associated with this session; should never be null.
-
getEnabledFilter
Retrieve a currently enabled filter by name.- Specified by:
getEnabledFilterin interfaceSession- Parameters:
filterName- The name of the filter to be retrieved.- Returns:
- The Filter instance representing the enabled filter.
-
enableFilter
Enable the named filter for this current session.- Specified by:
enableFilterin interfaceSession- Parameters:
filterName- The name of the filter to be enabled.- Returns:
- The Filter instance representing the enabled filter.
-
disableFilter
Disable the named filter for the current session.- Specified by:
disableFilterin interfaceSession- Parameters:
filterName- The name of the filter to be disabled.
-
getFilterParameterValue
Retreive the currently set value for a filter parameter.- Specified by:
getFilterParameterValuein interfaceSessionImplementor- Parameters:
filterParameterName- The filter parameter name in the format {FILTER_NAME.PARAMETER_NAME}.- Returns:
- The filter parameter value.
-
getFilterParameterType
Retreive the type for a given filter parrameter.- Specified by:
getFilterParameterTypein interfaceSessionImplementor- Parameters:
filterParameterName- The filter parameter name in the format {FILTER_NAME.PARAMETER_NAME}.- Returns:
- The filter param type
-
getEnabledFilters
Return the currently enabled filters. The filter map is keyed by filter name, with values corresponding to theFilterImplinstance.- Specified by:
getEnabledFiltersin interfaceSessionImplementor- Returns:
- The currently enabled filters.
-
getFetchProfile
Get the internal fetch profile currently associated with this session.- Specified by:
getFetchProfilein interfaceSessionImplementor- Returns:
- The current internal fetch profile, or null if none currently associated.
-
setFetchProfile
Set the current internal fetch profile for this session.- Specified by:
setFetchProfilein interfaceSessionImplementor- Parameters:
fetchProfile- The internal fetch profile name to use
-
isFetchProfileEnabled
Description copied from interface:SessionIs a particular fetch profile enabled on this session?- Specified by:
isFetchProfileEnabledin interfaceSession- Parameters:
name- The name of the profile to be checked.- Returns:
- True if fetch profile is enabled; false if not.
- Throws:
UnknownProfileException- Indicates that the given name does not match any known profile names- See Also:
-
enableFetchProfile
Description copied from interface:SessionEnable a particular fetch profile on this session. No-op if requested profile is already enabled.- Specified by:
enableFetchProfilein interfaceSession- Parameters:
name- The name of the fetch profile to be enabled.- Throws:
UnknownProfileException- Indicates that the given name does not match any known profile names- See Also:
-
disableFetchProfile
Description copied from interface:SessionDisable a particular fetch profile on this session. No-op if requested profile is already disabled.- Specified by:
disableFetchProfilein interfaceSession- Parameters:
name- The name of the fetch profile to be disabled.- Throws:
UnknownProfileException- Indicates that the given name does not match any known profile names- See Also:
-
execute
Execute the given callback, making sure it has access to a viable JDBCConnection.- Specified by:
executein interfaceLobCreationContext- Parameters:
callback- The callback to execute .- Returns:
- The LOB created by the callback.
-
getTypeHelper
Convenience access to theTypeHelperassociated with this session'sSessionFactory. Equivalent to callingSession.getSessionFactory().getTypeHelper()- Specified by:
getTypeHelperin interfaceSession- Returns:
- The
TypeHelperassociated with this session'sSessionFactory
-
getLobHelper
Retrieve this session's helper/delegate for creating LOB instances.- Specified by:
getLobHelperin interfaceSession- Returns:
- This session's LOB helper
-