Top Description Methods
org.hibernate.engine

public Interface SessionImplementor

extends Serializable
Known Direct Subinterfaces
org.hibernate.event.EventSource
Known Direct Implementers
org.hibernate.impl.AbstractSessionImpl
Imports
java.io.Serializable, java.sql.Connection, java.util.Iterator, .List, .Map, .Set, org.hibernate.CacheMode, .EntityMode, .FlushMode, .HibernateException, .Interceptor, .Query, .ScrollMode, .ScrollableResults, .Transaction, org.hibernate.engine.query.sql.NativeSQLQuerySpecification, org.hibernate.collection.PersistentCollection, org.hibernate.event.EventListeners, org.hibernate.impl.CriteriaImpl, org.hibernate.jdbc.Batcher, .JDBCContext, org.hibernate.loader.custom.CustomQuery, org.hibernate.persister.entity.EntityPersister, org.hibernate.type.Type

Defines the internal contract between the Session and other parts of Hibernate such as implementors of Type or EntityPersister.
Author
Gavin King
See Also
the interface to the application, the actual implementation

Method Summary

Modifier and TypeMethod and Description
public void
public void
afterTransactionCompletion(boolean successful, Transaction tx)

Notify the session that the transaction completed, so we no longer own the old locks.

public void
applyNonFlushedChanges(NonFlushedChanges
the non-flushed changes
nonFlushedChanges
)

Apply non-flushed changes from a different session to this session.

public void
beforeTransactionCompletion(Transaction tx)

Notify the session that the transaction is about to complete

public String
bestGuessEntityName(Object object)

The best guess entity name for an entity not in an association

public Connection
public int
executeNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters)

Execute a native SQL update or delete query

public int
executeUpdate(String query, QueryParameters queryParameters)

Execute a HQL update or delete query

public void
public Batcher
getBatcher()

Get the prepared statement Batcher for this session

public CacheMode
public Serializable
getContextEntityIdentifier(Object object)

Return the identifier of the persistent object, or null if not associated with the session

public int
public Map<K, V>

Returns:

The currently enabled filters.
getEnabledFilters
()

Deprecated use #getLoadQueryInfluencers instead
Return the currently enabled filters.
public EntityMode
public EntityPersister
getEntityPersister(String
optional entity name
entityName
,
Object
the entity instance
object
)

Get the EntityPersister for any instance

public Object
getEntityUsingInterceptor(EntityKey key)

Get the entity instance associated with the given Key, calling the Interceptor if necessary

public SessionFactoryImplementor
getFactory()

Get the creating SessionFactoryImplementor

public String

Returns:

The current internal fetch profile, or null if none currently associated.
getFetchProfile
()

Deprecated use #getLoadQueryInfluencers instead
Get the internal fetch profile currently associated with this session.
public Type

Returns:

The filter param type
getFilterParameterType
(String
The filter parameter name in the format {FILTER_NAME.PARAMETER_NAME}.
filterParameterName
)

Deprecated use #getLoadQueryInfluencers instead
Retreive the type for a given filter parrameter.
public Object

Returns:

The filter parameter value.
getFilterParameterValue
(String
The filter parameter name in the format {FILTER_NAME.PARAMETER_NAME}.
filterParameterName
)

Deprecated use #getLoadQueryInfluencers instead
Retreive the currently set value for a filter parameter.
public FlushMode
public Interceptor

Returns:

The interceptor.
getInterceptor
()

Retrieves the interceptor currently in use by this event source.

public JDBCContext
public EventListeners

Returns:

The configured event listeners.
getListeners
()

Retrieves the configured event listeners from this event source.

public LoadQueryInfluencers

Returns:

the load query influencers associated with this session; should never be null.
getLoadQueryInfluencers
()

Get the load query influencers associated with this session.

public Query
getNamedQuery(String name)

Get a Query instance for a named query or named native SQL query

public Query
getNamedSQLQuery(String name)

Get a Query instance for a named native SQL query

public NonFlushedChanges

Returns:

The non-flushed changes.
getNonFlushedChanges
()

Return changes to this session that have not been flushed yet.

public PersistenceContext
getPersistenceContext()

Get the persistence context for this session

public long
getTimestamp()

System time before the start of the transaction

public String
guessEntityName(Object entity)

The guessed entity name for an entity not in an association

public Object
immediateLoad(String entityName, Serializable id)

Load an instance immediately.

public void
initializeCollection(PersistentCollection collection, boolean writing)

Initialize the collection (if not already initialized)

public Object
instantiate(String entityName, Serializable id)

Instantiate the entity class, initializing with the given identifier

public Object
internalLoad(String entityName, Serializable id, boolean eager, boolean nullable)

Load an instance without checking if it was deleted.

public boolean

Returns:

True if the session is closed; false otherwise.
isClosed
()

Determine whether the session is closed.

public boolean
public boolean
public boolean
public boolean
isTransactionInProgress()

Does this Session have an active Hibernate transaction or is there a JTA transaction in progress?

public Iterator<E>
iterate(String query, QueryParameters queryParameters)

Execute an iterate() query

public Iterator<E>
iterateFilter(Object collection, String filter, QueryParameters queryParameters)

Iterate a filter

public List<E>
list(String query, QueryParameters queryParameters)

Execute a find() query

public List<E>
list(CriteriaImpl criteria)

Execute a criteria query

public List<E>

Returns:

The result list.
list
(NativeSQLQuerySpecification
The specification of the native SQL query to execute.
spec
,
QueryParameters
The parameters by which to perform the execution.
queryParameters
)

Execute a native SQL query, and return the results as a fully built list.

public List<E>
listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters)

Execute an SQL Query

public List<E>
listFilter(Object collection, String filter, QueryParameters queryParameters)

Execute a filter

public ScrollableResults
scroll(String query, QueryParameters queryParameters)

Execute a scroll() query

public ScrollableResults
scroll(CriteriaImpl criteria, ScrollMode scrollMode)

Execute a criteria query

public ScrollableResults

Returns:

The resulting scrollable result.
scroll
(NativeSQLQuerySpecification
The specification of the native SQL query to execute.
spec
,
QueryParameters
The parameters by which to perform the execution.
queryParameters
)

Execute a native SQL query, and return the results as a scrollable result.

public ScrollableResults
scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters)

Execute an SQL Query

public void
setAutoClear(boolean enabled)

Enable/disable automatic cache clearing from after transaction completion (for EJB3)

public void
public void
setFetchProfile(String
The internal fetch profile name to use
name
)

Deprecated use #getLoadQueryInfluencers instead
Set the current internal fetch profile for this session.
public void

Method Detail

afterScrollOperationback to summary
public void afterScrollOperation()
afterTransactionCompletionback to summary
public void afterTransactionCompletion(boolean successful, Transaction tx)

Notify 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.

applyNonFlushedChangesback to summary
public void applyNonFlushedChanges(NonFlushedChanges nonFlushedChanges) throws HibernateException

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.

Parameters
nonFlushedChanges:NonFlushedChanges

the non-flushed changes

beforeTransactionCompletionback to summary
public void beforeTransactionCompletion(Transaction tx)

Notify the session that the transaction is about to complete

bestGuessEntityNameback to summary
public String bestGuessEntityName(Object object)

The best guess entity name for an entity not in an association

connectionback to summary
public Connection connection()
executeNativeUpdateback to summary
public int executeNativeUpdate(NativeSQLQuerySpecification specification, QueryParameters queryParameters) throws HibernateException

Execute a native SQL update or delete query

executeUpdateback to summary
public int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException

Execute a HQL update or delete query

flushback to summary
public void flush()
getBatcherback to summary
public Batcher getBatcher()

Get the prepared statement Batcher for this session

getCacheModeback to summary
public CacheMode getCacheMode()
getContextEntityIdentifierback to summary
public Serializable getContextEntityIdentifier(Object object)

Return the identifier of the persistent object, or null if not associated with the session

getDontFlushFromFindback to summary
public int getDontFlushFromFind()
getEnabledFiltersback to summary
public Map<K, V> getEnabledFilters()

Deprecated

use #getLoadQueryInfluencers instead

Return the currently enabled filters. The filter map is keyed by filter name, with values corresponding to the org.hibernate.impl.FilterImpl instance.

Returns:Map<K, V>

The currently enabled filters.

getEntityModeback to summary
public EntityMode getEntityMode()
getEntityPersisterback to summary
public EntityPersister getEntityPersister(String entityName, Object object) throws HibernateException

Get the EntityPersister for any instance

Parameters
entityName:String

optional entity name

object:Object

the entity instance

getEntityUsingInterceptorback to summary
public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException

Get the entity instance associated with the given Key, calling the Interceptor if necessary

getFactoryback to summary
public SessionFactoryImplementor getFactory()

Get the creating SessionFactoryImplementor

getFetchProfileback to summary
public String getFetchProfile()

Deprecated

use #getLoadQueryInfluencers instead

Get the internal fetch profile currently associated with this session.

Returns:String

The current internal fetch profile, or null if none currently associated.

getFilterParameterTypeback to summary
public Type getFilterParameterType(String filterParameterName)

Deprecated

use #getLoadQueryInfluencers instead

Retreive the type for a given filter parrameter.

Parameters
filterParameterName:String

The filter parameter name in the format {FILTER_NAME.PARAMETER_NAME}.

Returns:Type

The filter param type

getFilterParameterValueback to summary
public Object getFilterParameterValue(String filterParameterName)

Deprecated

use #getLoadQueryInfluencers instead

Retreive the currently set value for a filter parameter.

Parameters
filterParameterName:String

The filter parameter name in the format {FILTER_NAME.PARAMETER_NAME}.

Returns:Object

The filter parameter value.

getFlushModeback to summary
public FlushMode getFlushMode()
getInterceptorback to summary
public Interceptor getInterceptor()

Retrieves the interceptor currently in use by this event source.

Returns:Interceptor

The interceptor.

getJDBCContextback to summary
public JDBCContext getJDBCContext()
getListenersback to summary
public EventListeners getListeners()

Retrieves the configured event listeners from this event source.

Returns:EventListeners

The configured event listeners.

getLoadQueryInfluencersback to summary
public LoadQueryInfluencers getLoadQueryInfluencers()

Get the load query influencers associated with this session.

Returns:LoadQueryInfluencers

the load query influencers associated with this session; should never be null.

getNamedQueryback to summary
public Query getNamedQuery(String name)

Get a Query instance for a named query or named native SQL query

getNamedSQLQueryback to summary
public Query getNamedSQLQuery(String name)

Get a Query instance for a named native SQL query

getNonFlushedChangesback to summary
public NonFlushedChanges getNonFlushedChanges() throws HibernateException

Return changes to this session that have not been flushed yet.

Returns:NonFlushedChanges

The non-flushed changes.

getPersistenceContextback to summary
public PersistenceContext getPersistenceContext()

Get the persistence context for this session

getTimestampback to summary
public long getTimestamp()

System time before the start of the transaction

guessEntityNameback to summary
public String guessEntityName(Object entity) throws HibernateException

The guessed entity name for an entity not in an association

immediateLoadback to summary
public Object immediateLoad(String entityName, Serializable id) throws HibernateException

Load an instance immediately. This method is only called when lazily initializing a proxy. Do not return the proxy.

initializeCollectionback to summary
public void initializeCollection(PersistentCollection collection, boolean writing) throws HibernateException

Initialize the collection (if not already initialized)

instantiateback to summary
public Object instantiate(String entityName, Serializable id) throws HibernateException

Instantiate the entity class, initializing with the given identifier

internalLoadback to summary
public Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) throws HibernateException

Load 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

isClosedback to summary
public boolean isClosed()

Determine whether the session is closed. Provided seperately from isOpen() as this method does not attempt any JTA synch registration, where as isOpen() does; which makes this one nicer to use for most internal purposes.

Returns:boolean

True if the session is closed; false otherwise.

isConnectedback to summary
public boolean isConnected()
isEventSourceback to summary
public boolean isEventSource()
isOpenback to summary
public boolean isOpen()
isTransactionInProgressback to summary
public boolean isTransactionInProgress()

Does this Session have an active Hibernate transaction or is there a JTA transaction in progress?

iterateback to summary
public Iterator<E> iterate(String query, QueryParameters queryParameters) throws HibernateException

Execute an iterate() query

iterateFilterback to summary
public Iterator<E> iterateFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException

Iterate a filter

listback to summary
public List<E> list(String query, QueryParameters queryParameters) throws HibernateException

Execute a find() query

listback to summary
public List<E> list(CriteriaImpl criteria)

Execute a criteria query

listback to summary
public List<E> list(NativeSQLQuerySpecification spec, QueryParameters queryParameters) throws HibernateException

Execute a native SQL query, and return the results as a fully built list.

Parameters
spec:NativeSQLQuerySpecification

The specification of the native SQL query to execute.

queryParameters:QueryParameters

The parameters by which to perform the execution.

Returns:List<E>

The result list.

listCustomQueryback to summary
public List<E> listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException

Execute an SQL Query

listFilterback to summary
public List<E> listFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException

Execute a filter

scrollback to summary
public ScrollableResults scroll(String query, QueryParameters queryParameters) throws HibernateException

Execute a scroll() query

scrollback to summary
public ScrollableResults scroll(CriteriaImpl criteria, ScrollMode scrollMode)

Execute a criteria query

scrollback to summary
public ScrollableResults scroll(NativeSQLQuerySpecification spec, QueryParameters queryParameters) throws HibernateException

Execute a native SQL query, and return the results as a scrollable result.

Parameters
spec:NativeSQLQuerySpecification

The specification of the native SQL query to execute.

queryParameters:QueryParameters

The parameters by which to perform the execution.

Returns:ScrollableResults

The resulting scrollable result.

scrollCustomQueryback to summary
public ScrollableResults scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException

Execute an SQL Query

setAutoClearback to summary
public void setAutoClear(boolean enabled)

Enable/disable automatic cache clearing from after transaction completion (for EJB3)

setCacheModeback to summary
public void setCacheMode(CacheMode cm)
setFetchProfileback to summary
public void setFetchProfile(String name)

Deprecated

use #getLoadQueryInfluencers instead

Set the current internal fetch profile for this session.

Parameters
name:String

The internal fetch profile name to use

setFlushModeback to summary
public void setFlushMode(FlushMode fm)