public interface

StatelessSession

implements Serializable
org.hibernate.StatelessSession
Known Indirect Subclasses

Class Overview

A command-oriented API for performing bulk operations against a database.

A stateless session does not implement a first-level cache nor interact with any second-level cache, nor does it implement transactional write-behind or automatic dirty checking, nor do operations cascade to associated instances. Collections are ignored by a stateless session. Operations performed via a stateless session bypass Hibernate's event model and interceptors. Stateless sessions are vulnerable to data aliasing effects, due to the lack of a first-level cache.

For certain kinds of transactions, a stateless session may perform slightly faster than a stateful session.

Summary

Public Methods
abstract Transaction beginTransaction()
Begin a Hibernate transaction.
abstract void close()
Close the stateless session and release the JDBC connection.
abstract Connection connection()
Returns the current JDBC connection associated with this instance.
abstract Criteria createCriteria(String entityName)
Create a new Criteria instance, for the given entity name.
abstract Criteria createCriteria(String entityName, String alias)
Create a new Criteria instance, for the given entity name, with the given alias.
abstract Criteria createCriteria(Class persistentClass)
Create a new Criteria instance, for the given entity class, or a superclass of an entity class.
abstract Criteria 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.
abstract Query createQuery(String queryString)
Create a new instance of Query for the given HQL query string.
abstract SQLQuery createSQLQuery(String queryString)
Create a new instance of SQLQuery for the given SQL query string.
abstract void delete(String entityName, Object entity)
Delete a row.
abstract void delete(Object entity)
Delete a row.
abstract Object get(String entityName, Serializable id, LockMode lockMode)
Retrieve a row, obtaining the specified lock mode.
abstract Object get(String entityName, Serializable id)
Retrieve a row.
abstract Object get(Class entityClass, Serializable id)
Retrieve a row.
abstract Object get(Class entityClass, Serializable id, LockMode lockMode)
Retrieve a row, obtaining the specified lock mode.
abstract Query getNamedQuery(String queryName)
Obtain an instance of Query for a named query string defined in the mapping file.
abstract Transaction getTransaction()
Get the current Hibernate transaction.
abstract Serializable insert(String entityName, Object entity)
Insert a row.
abstract Serializable insert(Object entity)
Insert a row.
abstract void refresh(String entityName, Object entity)
Refresh the entity instance state from the database.
abstract void refresh(String entityName, Object entity, LockMode lockMode)
Refresh the entity instance state from the database.
abstract void refresh(Object entity, LockMode lockMode)
Refresh the entity instance state from the database.
abstract void refresh(Object entity)
Refresh the entity instance state from the database.
abstract void update(String entityName, Object entity)
Update a row.
abstract void update(Object entity)
Update a row.

Public Methods

public abstract Transaction beginTransaction ()

Begin a Hibernate transaction.

public abstract void close ()

Close the stateless session and release the JDBC connection.

public abstract Connection 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. Otherwise, the application should not close the connection.

public abstract Criteria createCriteria (String entityName)

Create a new Criteria instance, for the given entity name. Entities returned by the query are detached.

Returns
  • Criteria

public abstract Criteria createCriteria (String entityName, String alias)

Create a new Criteria instance, for the given entity name, with the given alias. Entities returned by the query are detached.

Returns
  • Criteria

public abstract Criteria createCriteria (Class persistentClass)

Create a new Criteria instance, for the given entity class, or a superclass of an entity class. Entities returned by the query are detached.

Parameters
persistentClass a class, which is persistent, or has persistent subclasses
Returns
  • Criteria

public abstract Criteria 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. Entities returned by the query are detached.

Parameters
persistentClass a class, which is persistent, or has persistent subclasses
Returns
  • Criteria

public abstract Query createQuery (String queryString)

Create a new instance of Query for the given HQL query string. Entities returned by the query are detached.

public abstract SQLQuery createSQLQuery (String queryString)

Create a new instance of SQLQuery for the given SQL query string. Entities returned by the query are detached.

Parameters
queryString a SQL query
Returns
  • SQLQuery

public abstract void delete (String entityName, Object entity)

Delete a row.

Parameters
entityName The entityName for the entity to be deleted
entity a detached entity instance

public abstract void delete (Object entity)

Delete a row.

Parameters
entity a detached entity instance

public abstract Object get (String entityName, Serializable id, LockMode lockMode)

Retrieve a row, obtaining the specified lock mode.

Returns
  • a detached entity instance

public abstract Object get (String entityName, Serializable id)

Retrieve a row.

Returns
  • a detached entity instance

public abstract Object get (Class entityClass, Serializable id)

Retrieve a row.

Returns
  • a detached entity instance

public abstract Object get (Class entityClass, Serializable id, LockMode lockMode)

Retrieve a row, obtaining the specified lock mode.

Returns
  • a detached entity instance

public abstract Query getNamedQuery (String queryName)

Obtain an instance of Query for a named query string defined in the mapping file. Entities returned by the query are detached.

public abstract Transaction getTransaction ()

Get the current Hibernate transaction.

public abstract Serializable insert (String entityName, Object entity)

Insert a row.

Parameters
entityName The entityName for the entity to be inserted
entity a new transient instance
Returns
  • the identifier of the instance

public abstract Serializable insert (Object entity)

Insert a row.

Parameters
entity a new transient instance

public abstract void refresh (String entityName, Object entity)

Refresh the entity instance state from the database.

Parameters
entityName The entityName for the entity to be refreshed.
entity The entity to be refreshed.

public abstract void refresh (String entityName, Object entity, LockMode lockMode)

Refresh the entity instance state from the database.

Parameters
entityName The entityName for the entity to be refreshed.
entity The entity to be refreshed.
lockMode The LockMode to be applied.

public abstract void refresh (Object entity, LockMode lockMode)

Refresh the entity instance state from the database.

Parameters
entity The entity to be refreshed.
lockMode The LockMode to be applied.

public abstract void refresh (Object entity)

Refresh the entity instance state from the database.

Parameters
entity The entity to be refreshed.

public abstract void update (String entityName, Object entity)

Update a row.

Parameters
entityName The entityName for the entity to be updated
entity a detached entity instance

public abstract void update (Object entity)

Update a row.

Parameters
entity a detached entity instance