## org.hibernate.internal
Class AbstractSessionImpl

    java.lang.Object
      org.hibernate.internal.AbstractSessionImpl

All Implemented Interfaces:
  Serializable, LobCreationContext, SessionImplementor, TransactionContext, SharedSessionContract

Direct Known Subclasses:
  SessionImpl, StatelessSessionImpl

    public abstract class AbstractSessionImpl

extends Object
implements Serializable, SharedSessionContract, SessionImplementor, TransactionContext

Functionality common to stateless and stateful sessions

See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from interface org.hibernate.engine.jdbc.LobCreationContext
`LobCreationContext.Callback<T>`

Field Summary
`protected SessionFactoryImpl` `factory`

Constructor Summary
`protected` `AbstractSessionImpl(SessionFactoryImpl factory, String tenantIdentifier)`

Method Summary
`Query` `createQuery(String queryString)` Create a `Query` instance for the given HQL query string.
`SQLQuery` `createSQLQuery(String sql)` Create a `SQLQuery` instance for the given SQL query string.
`protected void` `errorIfClosed()`

`

`<T> T`

`

`execute(LobCreationContext.Callback<T> callback)`
Execute the given callback, making sure it has access to a viable JDBC `Connection`.

`CacheKey` `generateCacheKey(Serializable id, Type type, String entityOrRoleName)` Hide the changing requirements of cache key creation.
`EntityKey` `generateEntityKey(Serializable id, EntityPersister persister)` Hide the changing requirements of entity key creation
`SessionFactoryImplementor` `getFactory()` Get the creating `SessionFactoryImplementor`
`protected HQLQueryPlan` `getHQLQueryPlan(String query, boolean shallow)`
`JdbcConnectionAccess` `getJdbcConnectionAccess()` Provides access to JDBC connections
`Query` `getNamedQuery(String queryName)` Create a `Query` instance for the named query string defined in the metadata.
`Query` `getNamedSQLQuery(String queryName)` Get a Query instance for a named native SQL query
`protected NativeSQLQueryPlan` `getNativeSQLQueryPlan(NativeSQLQuerySpecification spec)`
`String` `getTenantIdentifier()` Obtain the tenant identifier associated with this session.
`TransactionEnvironment` `getTransactionEnvironment()` Obtain the `TransactionEnvironment` associated with this context.
`boolean` `isClosed()` Determine whether the session is closed.
`List` `list(NativeSQLQuerySpecification spec, QueryParameters queryParameters)` Execute a native SQL query, and return the results as a fully built list.
`ScrollableResults` `scroll(NativeSQLQuerySpecification spec, QueryParameters queryParameters)` Execute a native SQL query, and return the results as a scrollable result.
`protected void` `setClosed()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.hibernate.SharedSessionContract
`beginTransaction, createCriteria, createCriteria, createCriteria, createCriteria, getTransaction`

Methods inherited from interface org.hibernate.engine.spi.SessionImplementor

`afterScrollOperation, applyNonFlushedChanges, bestGuessEntityName, connection, disableTransactionAutoJoin, executeNativeUpdate, executeUpdate, flush, getCacheMode, getContextEntityIdentifier, getDontFlushFromFind, getEnabledFilters, getEntityPersister, getEntityUsingInterceptor, getFetchProfile, getFilterParameterType, getFilterParameterValue, getFlushMode, getInterceptor, getLoadQueryInfluencers, getNonFlushedChanges, getPersistenceContext, getTimestamp, getTransactionCoordinator, guessEntityName, immediateLoad, initializeCollection, instantiate, internalLoad, isConnected, isEventSource, isOpen, isTransactionInProgress, iterate, iterateFilter, list, list, listCustomQuery, listFilter, scroll, scroll, scrollCustomQuery, setAutoClear, setCacheMode, setFetchProfile, setFlushMode`

Methods inherited from interface org.hibernate.engine.transaction.spi.TransactionContext
`afterTransactionBegin, afterTransactionCompletion, beforeTransactionCompletion, getConnectionReleaseMode, isAutoCloseSessionEnabled, isFlushBeforeCompletionEnabled, isFlushModeNever, managedClose, managedFlush, onPrepareStatement, shouldAutoClose, shouldAutoJoinTransaction`

Field Detail

### factory

    protected transient SessionFactoryImpl factory

Constructor Detail

### AbstractSessionImpl

    protected AbstractSessionImpl(SessionFactoryImpl factory,
                                  String tenantIdentifier)

Method Detail

### getFactory

    public SessionFactoryImplementor getFactory()

  Description copied from interface: `SessionImplementor`
  Get the creating `SessionFactoryImplementor`

  Specified by:
    `getFactory` in interface `SessionImplementor`

### getTransactionEnvironment

    public TransactionEnvironment getTransactionEnvironment()

  Description copied from interface: `TransactionContext`
  Obtain the `TransactionEnvironment` associated with this context.

  Specified by:
    `getTransactionEnvironment` in interface `TransactionContext`
  Returns:
    The transaction environment.

### execute

    public <T> T execute(LobCreationContext.Callback<T> callback)

  Description copied from interface: `LobCreationContext`
  Execute the given callback, making sure it has access to a viable JDBC `Connection`.

  Specified by:
    `execute` in interface `LobCreationContext`
  Parameters:
    `callback` - The callback to execute .
  Returns:
    The LOB created by the callback.

### isClosed

    public boolean isClosed()

  Description copied from interface: `SessionImplementor`
  Determine whether the session is closed. Provided separately from `SessionImplementor.isOpen()` as this method does not attempt any JTA synchronization registration, where as `SessionImplementor.isOpen()` does; which makes this one nicer to use for most internal purposes.

  Specified by:
    `isClosed` in interface `SessionImplementor`
  Specified by:
    `isClosed` in interface `TransactionContext`
  Returns:
    True if the session is closed; false otherwise.

### setClosed

    protected void setClosed()

### errorIfClosed

    protected void errorIfClosed()

### getNamedQuery

    public Query getNamedQuery(String queryName)
                        throws MappingException

  Description copied from interface: `SharedSessionContract`
  Create a `Query` instance for the named query string defined in the metadata.

  Specified by:
    `getNamedQuery` in interface `SessionImplementor`
  Specified by:
    `getNamedQuery` in interface `SharedSessionContract`
  Parameters:
    `queryName` - the name of a query defined externally
  Returns:
    The query instance for manipulation and execution
  Throws:
    `MappingException`

### getNamedSQLQuery

    public Query getNamedSQLQuery(String queryName)
                           throws MappingException

  Description copied from interface: `SessionImplementor`
  Get a Query instance for a named native SQL query

  Specified by:
    `getNamedSQLQuery` in interface `SessionImplementor`
  Throws:
    `MappingException`

### createQuery

    public Query createQuery(String queryString)

  Description copied from interface: `SharedSessionContract`
  Create a `Query` instance for the given HQL query string.

  Specified by:
    `createQuery` in interface `SharedSessionContract`
  Parameters:
    `queryString` - The HQL query
  Returns:
    The query instance for manipulation and execution

### createSQLQuery

    public SQLQuery createSQLQuery(String sql)

  Description copied from interface: `SharedSessionContract`
  Create a `SQLQuery` instance for the given SQL query string.

  Specified by:
    `createSQLQuery` in interface `SharedSessionContract`
  Parameters:
    `sql` - The SQL query
  Returns:
    The query instance for manipulation and execution

### getHQLQueryPlan

    protected HQLQueryPlan getHQLQueryPlan(String query,
                                           boolean shallow)
                                    throws HibernateException

  Throws:
    `HibernateException`

### getNativeSQLQueryPlan

    protected NativeSQLQueryPlan getNativeSQLQueryPlan(NativeSQLQuerySpecification spec)
                                                throws HibernateException

  Throws:
    `HibernateException`

### list

    public List list(NativeSQLQuerySpecification spec,
                     QueryParameters queryParameters)
              throws HibernateException

  Description copied from interface: `SessionImplementor`
  Execute a native SQL query, and return the results as a fully built list.

  Specified by:
    `list` in interface `SessionImplementor`
  Parameters:
    `spec` - The specification of the native SQL query to execute.
    `queryParameters` - The parameters by which to perform the execution.
  Returns:
    The result list.
  Throws:
    `HibernateException`

### scroll

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

  Description copied from interface: `SessionImplementor`
  Execute a native SQL query, and return the results as a scrollable result.

  Specified by:
    `scroll` in interface `SessionImplementor`
  Parameters:
    `spec` - The specification of the native SQL query to execute.
    `queryParameters` - The parameters by which to perform the execution.
  Returns:
    The resulting scrollable result.
  Throws:
    `HibernateException`

### getTenantIdentifier

    public String getTenantIdentifier()

  Description copied from interface: `SharedSessionContract`
  Obtain the tenant identifier associated with this session.

  Specified by:
    `getTenantIdentifier` in interface `SessionImplementor`
  Specified by:
    `getTenantIdentifier` in interface `SharedSessionContract`
  Returns:
    The tenant identifier associated with this session, or `null`

### generateEntityKey

    public EntityKey generateEntityKey(Serializable id,
                                       EntityPersister persister)

  Description copied from interface: `SessionImplementor`
  Hide the changing requirements of entity key creation

  Specified by:
    `generateEntityKey` in interface `SessionImplementor`
  Parameters:
    `id` - The entity id
    `persister` - The entity persister
  Returns:
    The entity key

### generateCacheKey

    public CacheKey generateCacheKey(Serializable id,
                                     Type type,
                                     String entityOrRoleName)

  Description copied from interface: `SessionImplementor`
  Hide the changing requirements of cache key creation.

  Specified by:
    `generateCacheKey` in interface `SessionImplementor`
  Parameters:
    `id` - The entity identifier or collection key.
    `type` - The type
    `entityOrRoleName` - The entity name or collection role.
  Returns:
    The cache key

### getJdbcConnectionAccess

    public JdbcConnectionAccess getJdbcConnectionAccess()

  Description copied from interface: `SessionImplementor`
  Provides access to JDBC connections

  Specified by:
    `getJdbcConnectionAccess` in interface `SessionImplementor`
  Specified by:
    `getJdbcConnectionAccess` in interface `TransactionContext`
  Returns:
    The contract for accessing JDBC connections.

Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.