Top Description Methods
org.hibernate

public Interface StatelessSession

extends Serializable
Known Direct Implementers
org.hibernate.impl.StatelessSessionImpl
Imports
java.io.Serializable, java.sql.Connection

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.

Author
Gavin King

Method Summary

Modifier and TypeMethod and Description
public Transaction
beginTransaction()

Begin a Hibernate transaction.

public void
close()

Close the stateless session and release the JDBC connection.

public Connection
connection()

Returns the current JDBC connection associated with this instance.

public Criteria

Returns:

Criteria
createCriteria
(Class<T>
a class, which is persistent, or has persistent subclasses
persistentClass
)

Create a new Criteria instance, for the given entity class, or a superclass of an entity class.

public Criteria

Returns:

Criteria
createCriteria
(Class<T>
a class, which is persistent, or has persistent subclasses
persistentClass
,
String alias)

Create a new Criteria instance, for the given entity class, or a superclass of an entity class, with the given alias.

public Criteria

Returns:

Criteria
createCriteria
(String entityName)

Create a new Criteria instance, for the given entity name.

public Criteria

Returns:

Criteria
createCriteria
(String entityName, String alias)

Create a new Criteria instance, for the given entity name, with the given alias.

public Query
createQuery(String queryString)

Create a new instance of Query for the given HQL query string.

public SQLQuery

Returns:

SQLQuery
createSQLQuery
(String
a SQL query
queryString
)

Create a new instance of SQLQuery for the given SQL query string.

public void
delete(Object
a detached entity instance
entity
)

Delete a row.

public void
delete(String
The entityName for the entity to be deleted
entityName
,
Object
a detached entity instance
entity
)

Delete a row.

public Object

Returns:

a detached entity instance
get
(String entityName, Serializable id)

Retrieve a row.

public Object

Returns:

a detached entity instance
get
(Class<T> entityClass, Serializable id)

Retrieve a row.

public Object

Returns:

a detached entity instance
get
(String entityName, Serializable id, LockMode lockMode)

Retrieve a row, obtaining the specified lock mode.

public Object

Returns:

a detached entity instance
get
(Class<T> entityClass, Serializable id, LockMode lockMode)

Retrieve a row, obtaining the specified lock mode.

public Query
getNamedQuery(String queryName)

Obtain an instance of Query for a named query string defined in the mapping file.

public Transaction
getTransaction()

Get the current Hibernate transaction.

public Serializable
insert(Object
a new transient instance
entity
)

Insert a row.

public Serializable

Returns:

the identifier of the instance
insert
(String
The entityName for the entity to be inserted
entityName
,
Object
a new transient instance
entity
)

Insert a row.

public void
refresh(Object
The entity to be refreshed.
entity
)

Refresh the entity instance state from the database.

public void
refresh(String
The entityName for the entity to be refreshed.
entityName
,
Object
The entity to be refreshed.
entity
)

Refresh the entity instance state from the database.

public void
refresh(Object
The entity to be refreshed.
entity
,
LockMode
The LockMode to be applied.
lockMode
)

Refresh the entity instance state from the database.

public void
refresh(String
The entityName for the entity to be refreshed.
entityName
,
Object
The entity to be refreshed.
entity
,
LockMode
The LockMode to be applied.
lockMode
)

Refresh the entity instance state from the database.

public void
update(Object
a detached entity instance
entity
)

Update a row.

public void
update(String
The entityName for the entity to be updated
entityName
,
Object
a detached entity instance
entity
)

Update a row.

Method Detail

beginTransactionback to summary
public Transaction beginTransaction()

Begin a Hibernate transaction.

closeback to summary
public void close()

Close the stateless session and release the JDBC connection.

connectionback to summary
public 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.

createCriteriaback to summary
public Criteria createCriteria(Class<T> 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:Class<T>

a class, which is persistent, or has persistent subclasses

Returns:Criteria

Criteria

createCriteriaback to summary
public Criteria createCriteria(Class<T> 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:Class<T>

a class, which is persistent, or has persistent subclasses

Returns:Criteria

Criteria

createCriteriaback to summary
public Criteria createCriteria(String entityName)

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

Returns:Criteria

Criteria

createCriteriaback to summary
public 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

Criteria

createQueryback to summary
public Query createQuery(String queryString)

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

createSQLQueryback to summary
public SQLQuery createSQLQuery(String queryString) throws HibernateException

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

Parameters
queryString:String

a SQL query

Returns:SQLQuery

SQLQuery

deleteback to summary
public void delete(Object entity)

Delete a row.

Parameters
entity:Object

a detached entity instance

deleteback to summary
public void delete(String entityName, Object entity)

Delete a row.

Parameters
entityName:String

The entityName for the entity to be deleted

entity:Object

a detached entity instance

getback to summary
public Object get(String entityName, Serializable id)

Retrieve a row.

Returns:Object

a detached entity instance

getback to summary
public Object get(Class<T> entityClass, Serializable id)

Retrieve a row.

Returns:Object

a detached entity instance

getback to summary
public Object get(String entityName, Serializable id, LockMode lockMode)

Retrieve a row, obtaining the specified lock mode.

Returns:Object

a detached entity instance

getback to summary
public Object get(Class<T> entityClass, Serializable id, LockMode lockMode)

Retrieve a row, obtaining the specified lock mode.

Returns:Object

a detached entity instance

getNamedQueryback to summary
public 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.

getTransactionback to summary
public Transaction getTransaction()

Get the current Hibernate transaction.

insertback to summary
public Serializable insert(Object entity)

Insert a row.

Parameters
entity:Object

a new transient instance

insertback to summary
public Serializable insert(String entityName, Object entity)

Insert a row.

Parameters
entityName:String

The entityName for the entity to be inserted

entity:Object

a new transient instance

Returns:Serializable

the identifier of the instance

refreshback to summary
public void refresh(Object entity)

Refresh the entity instance state from the database.

Parameters
entity:Object

The entity to be refreshed.

refreshback to summary
public void refresh(String entityName, Object entity)

Refresh the entity instance state from the database.

Parameters
entityName:String

The entityName for the entity to be refreshed.

entity:Object

The entity to be refreshed.

refreshback to summary
public void refresh(Object entity, LockMode lockMode)

Refresh the entity instance state from the database.

Parameters
entity:Object

The entity to be refreshed.

lockMode:LockMode

The LockMode to be applied.

refreshback to summary
public void refresh(String entityName, Object entity, LockMode lockMode)

Refresh the entity instance state from the database.

Parameters
entityName:String

The entityName for the entity to be refreshed.

entity:Object

The entity to be refreshed.

lockMode:LockMode

The LockMode to be applied.

updateback to summary
public void update(Object entity)

Update a row.

Parameters
entity:Object

a detached entity instance

updateback to summary
public void update(String entityName, Object entity)

Update a row.

Parameters
entityName:String

The entityName for the entity to be updated

entity:Object

a detached entity instance