Package org.hibernate.impl
Class StatelessSessionImpl
java.lang.Object
org.hibernate.impl.AbstractSessionImpl
org.hibernate.impl.StatelessSessionImpl
- All Implemented Interfaces:
Serializable,SessionImplementor,JDBCContext.Context,StatelessSession,TransactionFactory.Context
public class StatelessSessionImpl
extends AbstractSessionImpl
implements JDBCContext.Context, StatelessSession
- See Also:
-
Field Summary
Fields inherited from class org.hibernate.impl.AbstractSessionImpl
factory -
Method Summary
Modifier and TypeMethodDescriptionvoidafterOperation(boolean success) voidvoidWe cannot rely upon this method being called! It is only called if we are using Hibernate Transaction API.voidafterTransactionCompletion(boolean successful, 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) voidNotify the session that the transaction is about to completeBegin a Hibernate transaction.bestGuessEntityName(Object object) The best guess entity name for an entity not in an associationvoidclose()Close the stateless session and release the JDBC connection.Returns the current JDBC connection associated with this instance.
If the session is using aggressive connection release (as in a CMT environment), it is the application's responsibility to close the connection returned by this call.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.voidDelete a row.voidDelete a row.intexecuteNativeUpdate(NativeSQLQuerySpecification nativeSQLQuerySpecification, QueryParameters queryParameters) Execute a native SQL update or delete queryintexecuteUpdate(String query, QueryParameters queryParameters) Execute a HQL update or delete queryvoidflush()get(Class entityClass, Serializable id) Retrieve a row.get(Class entityClass, Serializable id, LockMode lockMode) Retrieve a row, obtaining the specified lock mode.get(String entityName, Serializable id) Retrieve a row.get(String entityName, Serializable id, LockMode lockMode) Retrieve a row, obtaining the specified lock mode.Get the prepared statement Batcher for this sessiongetContextEntityIdentifier(Object object) Return the identifier of the persistent object, or null if not associated with the sessionintReturn the currently enabled filters.getEntityPersister(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.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.Return changes to this session that have not been flushed yet.Get the persistence context for this sessionlongSystem time before the start of the transactionGet the current Hibernate transaction.guessEntityName(Object entity) The guessed entity name for an entity not in an associationimmediateLoad(String entityName, Serializable id) Load an instance immediately.voidinitializeCollection(PersistentCollection collection, boolean writing) Initialize the collection (if not already initialized)Insert a row.Insert a row.instantiate(String entityName, Serializable id) Instantiate the entity class, initializing with the given identifierinternalLoad(String entityName, Serializable id, boolean eager, boolean nullable) Load an instance without checking if it was deleted.booleanbooleanbooleanbooleanbooleanbooleanbooleanisOpen()booleanDoes this Session have an active Hibernate transaction or is there a JTA transaction in progress?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 filtervoidvoidvoidRefresh the entity instance state from the database.voidRefresh the entity instance state from the database.voidRefresh the entity instance state from the database.voidRefresh the entity instance state from the database.voidregisterInsertedKey(EntityPersister persister, Serializable id) scroll(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)voidvoidsetDefaultReadOnly(boolean readOnly) voidsetFetchProfile(String name) Set the current internal fetch profile for this session.voidbooleanvoidUpdate a row.voidUpdate a row.booleanwasInsertedDuringTransaction(EntityPersister persister, Serializable id) Methods inherited from class org.hibernate.impl.AbstractSessionImpl
createQuery, createSQLQuery, errorIfClosed, getFactory, getHQLQueryPlan, getNamedQuery, getNamedSQLQuery, getNativeSQLQueryPlan, isClosed, list, scroll, setClosedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.StatelessSession
createQuery, createSQLQuery, getNamedQueryMethods inherited from interface org.hibernate.transaction.TransactionFactory.Context
getFactory, isClosed
-
Method Details
-
insert
Description copied from interface:StatelessSessionInsert a row.- Specified by:
insertin interfaceStatelessSession- Parameters:
entity- a new transient instance
-
insert
Description copied from interface:StatelessSessionInsert a row.- Specified by:
insertin interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be insertedentity- a new transient instance- Returns:
- the identifier of the instance
-
delete
Description copied from interface:StatelessSessionDelete a row.- Specified by:
deletein interfaceStatelessSession- Parameters:
entity- a detached entity instance
-
delete
Description copied from interface:StatelessSessionDelete a row.- Specified by:
deletein interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be deletedentity- a detached entity instance
-
update
Description copied from interface:StatelessSessionUpdate a row.- Specified by:
updatein interfaceStatelessSession- Parameters:
entity- a detached entity instance
-
update
Description copied from interface:StatelessSessionUpdate a row.- Specified by:
updatein interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be updatedentity- a detached entity instance
-
get
Description copied from interface:StatelessSessionRetrieve a row.- Specified by:
getin interfaceStatelessSession- Returns:
- a detached entity instance
-
get
Description copied from interface:StatelessSessionRetrieve a row, obtaining the specified lock mode.- Specified by:
getin interfaceStatelessSession- Returns:
- a detached entity instance
-
get
Description copied from interface:StatelessSessionRetrieve a row.- Specified by:
getin interfaceStatelessSession- Returns:
- a detached entity instance
-
get
Description copied from interface:StatelessSessionRetrieve a row, obtaining the specified lock mode.- Specified by:
getin interfaceStatelessSession- Returns:
- a detached entity instance
-
refresh
Description copied from interface:StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceStatelessSession- Parameters:
entity- The entity to be refreshed.
-
refresh
Description copied from interface:StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be refreshed.entity- The entity to be refreshed.
-
refresh
Description copied from interface:StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceStatelessSession- Parameters:
entity- The entity to be refreshed.lockMode- The LockMode to be applied.
-
refresh
Description copied from interface:StatelessSessionRefresh the entity instance state from the database.- Specified by:
refreshin interfaceStatelessSession- Parameters:
entityName- The entityName for the entity to be refreshed.entity- The entity to be refreshed.lockMode- The LockMode to be applied.
-
immediateLoad
Description copied from interface:SessionImplementorLoad an instance immediately. This method is only called when lazily initializing a proxy. Do not return the proxy.- Specified by:
immediateLoadin interfaceSessionImplementor- Throws:
HibernateException
-
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
-
instantiate
Description copied from interface:SessionImplementorInstantiate the entity class, initializing with the given identifier- Specified by:
instantiatein 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
-
iterate
Description copied from interface:SessionImplementorExecute an iterate() query- Specified by:
iteratein 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
-
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
-
isOpen
public boolean isOpen()- Specified by:
isOpenin interfaceSessionImplementor
-
close
public void close()Description copied from interface:StatelessSessionClose the stateless session and release the JDBC connection.- Specified by:
closein interfaceStatelessSession
-
getConnectionReleaseMode
- Specified by:
getConnectionReleaseModein interfaceJDBCContext.Context
-
isAutoCloseSessionEnabled
public boolean isAutoCloseSessionEnabled()- Specified by:
isAutoCloseSessionEnabledin interfaceJDBCContext.Context
-
isFlushBeforeCompletionEnabled
public boolean isFlushBeforeCompletionEnabled()- Specified by:
isFlushBeforeCompletionEnabledin interfaceTransactionFactory.Context
-
isFlushModeNever
public boolean isFlushModeNever()- Specified by:
isFlushModeNeverin interfaceTransactionFactory.Context
-
managedClose
public void managedClose()- Specified by:
managedClosein interfaceTransactionFactory.Context
-
managedFlush
public void managedFlush()- Specified by:
managedFlushin interfaceTransactionFactory.Context
-
shouldAutoClose
public boolean shouldAutoClose()- Specified by:
shouldAutoClosein interfaceTransactionFactory.Context
-
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
-
beforeTransactionCompletion
Description copied from interface:SessionImplementorNotify the session that the transaction is about to complete- Specified by:
beforeTransactionCompletionin interfaceJDBCContext.Context- Specified by:
beforeTransactionCompletionin interfaceSessionImplementor
-
bestGuessEntityName
Description copied from interface:SessionImplementorThe best guess entity name for an entity not in an association- Specified by:
bestGuessEntityNamein interfaceSessionImplementor
-
connection
Description copied from interface:StatelessSessionReturns the current JDBC connection associated with this instance.
If the session is using aggressive connection 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 interfaceSessionImplementor- Specified by:
connectionin interfaceStatelessSession
-
executeUpdate
Description copied from interface:SessionImplementorExecute a HQL update or delete query- Specified by:
executeUpdatein interfaceSessionImplementor- Throws:
HibernateException
-
getBatcher
Description copied from interface:SessionImplementorGet the prepared statement Batcher for this session- Specified by:
getBatcherin interfaceSessionImplementor
-
getCacheMode
- Specified by:
getCacheModein interfaceSessionImplementor
-
getDontFlushFromFind
public int getDontFlushFromFind()- Specified by:
getDontFlushFromFindin interfaceSessionImplementor
-
getEnabledFilters
Description copied from interface:SessionImplementorReturn 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.
-
getContextEntityIdentifier
Description copied from interface:SessionImplementorReturn the identifier of the persistent object, or null if not associated with the session- Specified by:
getContextEntityIdentifierin interfaceSessionImplementor
-
getEntityMode
- Specified by:
getEntityModein interfaceSessionImplementor
-
getEntityPersister
public EntityPersister getEntityPersister(String entityName, Object object) throws HibernateException Description copied from interface:SessionImplementorGet the EntityPersister for any instance- Specified by:
getEntityPersisterin interfaceSessionImplementor- Parameters:
entityName- optional entity nameobject- the entity instance- 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
-
getFilterParameterType
Description copied from interface:SessionImplementorRetreive 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
-
getFilterParameterValue
Description copied from interface:SessionImplementorRetreive 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.
-
getFlushMode
- Specified by:
getFlushModein interfaceSessionImplementor
-
getInterceptor
Description copied from interface:SessionImplementorRetrieves the interceptor currently in use by this event source.- Specified by:
getInterceptorin interfaceSessionImplementor- Returns:
- The interceptor.
-
getListeners
Description copied from interface:SessionImplementorRetrieves the configured event listeners from this event source.- Specified by:
getListenersin interfaceSessionImplementor- Returns:
- The configured event listeners.
-
getPersistenceContext
Description copied from interface:SessionImplementorGet the persistence context for this session- Specified by:
getPersistenceContextin interfaceSessionImplementor
-
getTimestamp
public long getTimestamp()Description copied from interface:SessionImplementorSystem time before the start of the transaction- Specified by:
getTimestampin interfaceSessionImplementor
-
guessEntityName
Description copied from interface:SessionImplementorThe guessed entity name for an entity not in an association- Specified by:
guessEntityNamein interfaceSessionImplementor- Throws:
HibernateException
-
isConnected
public boolean isConnected()- Specified by:
isConnectedin interfaceSessionImplementor
-
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
-
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
-
setCacheMode
- Specified by:
setCacheModein interfaceSessionImplementor
-
setFlushMode
- Specified by:
setFlushModein interfaceSessionImplementor
-
getTransaction
Description copied from interface:StatelessSessionGet the current Hibernate transaction.- Specified by:
getTransactionin interfaceStatelessSession- Throws:
HibernateException
-
beginTransaction
Description copied from interface:StatelessSessionBegin a Hibernate transaction.- Specified by:
beginTransactionin interfaceStatelessSession- Throws:
HibernateException
-
isEventSource
public boolean isEventSource()- Specified by:
isEventSourcein interfaceSessionImplementor
-
isDefaultReadOnly
public boolean isDefaultReadOnly() -
setDefaultReadOnly
- Throws:
HibernateException
-
list
Description copied from interface:SessionImplementorExecute a find() query- Specified by:
listin interfaceSessionImplementor- Throws:
HibernateException
-
afterOperation
public void afterOperation(boolean success) -
createCriteria
Description copied from interface:StatelessSessionCreate a new Criteria instance, for the given entity class, or a superclass of an entity class, with the given alias. Entities returned by the query are detached.- Specified by:
createCriteriain interfaceStatelessSession- Parameters:
persistentClass- a class, which is persistent, or has persistent subclasses- Returns:
- Criteria
-
createCriteria
Description copied from interface:StatelessSessionCreate a new Criteria instance, for the given entity name, with the given alias. Entities returned by the query are detached.- Specified by:
createCriteriain interfaceStatelessSession- Parameters:
entityName-- Returns:
- Criteria
-
createCriteria
Description copied from interface:StatelessSessionCreate a new Criteria instance, for the given entity class, or a superclass of an entity class. Entities returned by the query are detached.- Specified by:
createCriteriain interfaceStatelessSession- Parameters:
persistentClass- a class, which is persistent, or has persistent subclasses- Returns:
- Criteria
-
createCriteria
Description copied from interface:StatelessSessionCreate a new Criteria instance, for the given entity name. Entities returned by the query are detached.- Specified by:
createCriteriain interfaceStatelessSession- 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
-
listCustomQuery
public List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException Description copied from interface:SessionImplementorExecute an SQL Query- Specified by:
listCustomQueryin interfaceSessionImplementor- Throws:
HibernateException
-
scrollCustomQuery
public ScrollableResults scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException Description copied from interface:SessionImplementorExecute an SQL Query- Specified by:
scrollCustomQueryin 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
-
afterScrollOperation
public void afterScrollOperation()- Specified by:
afterScrollOperationin interfaceSessionImplementor
-
flush
public void flush()- Specified by:
flushin interfaceSessionImplementor
-
getNonFlushedChanges
Description copied from interface:SessionImplementorReturn changes to this session that have not been flushed yet.- Specified by:
getNonFlushedChangesin interfaceSessionImplementor- Returns:
- The non-flushed changes.
-
applyNonFlushedChanges
Description copied from interface:SessionImplementorApply 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
-
getFetchProfile
Description copied from interface:SessionImplementorGet 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.
-
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.
-
registerInsertedKey
-
wasInsertedDuringTransaction
-
setFetchProfile
Description copied from interface:SessionImplementorSet the current internal fetch profile for this session.- Specified by:
setFetchProfilein interfaceSessionImplementor- Parameters:
name- The internal fetch profile name to use
-
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
-
autoFlushIfRequired
- Throws:
HibernateException
-
executeNativeUpdate
public int executeNativeUpdate(NativeSQLQuerySpecification nativeSQLQuerySpecification, QueryParameters queryParameters) throws HibernateException Description copied from interface:SessionImplementorExecute a native SQL update or delete query- Specified by:
executeNativeUpdatein interfaceSessionImplementor- Throws:
HibernateException
-