/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
 */
package org.hibernate;

import java.io.Closeable;
import java.io.Serializable;
import 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
/** * A command-oriented API for performing bulk operations against a database. * <p/> * 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. * <p/> * For certain kinds of transactions, a stateless session may perform slightly * faster than a stateful session. * * @author Gavin King */
public interface StatelessSession extends SharedSessionContract, AutoCloseable, Closeable {
Close the stateless session and release the JDBC connection.
/** * Close the stateless session and release the JDBC connection. */
void close();
Insert a row.
Params:
  • entity – a new transient instance
Returns:The identifier of the inserted entity
/** * Insert a row. * * @param entity a new transient instance * * @return The identifier of the inserted entity */
Serializable insert(Object entity);
Insert a row.
Params:
  • entityName – The entityName for the entity to be inserted
  • entity – a new transient instance
Returns:the identifier of the instance
/** * Insert a row. * * @param entityName The entityName for the entity to be inserted * @param entity a new transient instance * * @return the identifier of the instance */
Serializable insert(String entityName, Object entity);
Update a row.
Params:
  • entity – a detached entity instance
/** * Update a row. * * @param entity a detached entity instance */
void update(Object entity);
Update a row.
Params:
  • entityName – The entityName for the entity to be updated
  • entity – a detached entity instance
/** * Update a row. * * @param entityName The entityName for the entity to be updated * @param entity a detached entity instance */
void update(String entityName, Object entity);
Delete a row.
Params:
  • entity – a detached entity instance
/** * Delete a row. * * @param entity a detached entity instance */
void delete(Object entity);
Delete a row.
Params:
  • entityName – The entityName for the entity to be deleted
  • entity – a detached entity instance
/** * Delete a row. * * @param entityName The entityName for the entity to be deleted * @param entity a detached entity instance */
void delete(String entityName, Object entity);
Retrieve a row.
Params:
  • entityName – The name of the entity to retrieve
  • id – The id of the entity to retrieve
Returns:a detached entity instance
/** * Retrieve a row. * * @param entityName The name of the entity to retrieve * @param id The id of the entity to retrieve * * @return a detached entity instance */
Object get(String entityName, Serializable id);
Retrieve a row.
Params:
  • entityClass – The class of the entity to retrieve
  • id – The id of the entity to retrieve
Returns:a detached entity instance
/** * Retrieve a row. * * @param entityClass The class of the entity to retrieve * @param id The id of the entity to retrieve * * @return a detached entity instance */
Object get(Class entityClass, Serializable id);
Retrieve a row, obtaining the specified lock mode.
Params:
  • entityName – The name of the entity to retrieve
  • id – The id of the entity to retrieve
  • lockMode – The lock mode to apply to the entity
Returns:a detached entity instance
/** * Retrieve a row, obtaining the specified lock mode. * * @param entityName The name of the entity to retrieve * @param id The id of the entity to retrieve * @param lockMode The lock mode to apply to the entity * * @return a detached entity instance */
Object get(String entityName, Serializable id, LockMode lockMode);
Retrieve a row, obtaining the specified lock mode.
Params:
  • entityClass – The class of the entity to retrieve
  • id – The id of the entity to retrieve
  • lockMode – The lock mode to apply to the entity
Returns:a detached entity instance
/** * Retrieve a row, obtaining the specified lock mode. * * @param entityClass The class of the entity to retrieve * @param id The id of the entity to retrieve * @param lockMode The lock mode to apply to the entity * * @return a detached entity instance */
Object get(Class entityClass, Serializable id, LockMode lockMode);
Refresh the entity instance state from the database.
Params:
  • entity – The entity to be refreshed.
/** * Refresh the entity instance state from the database. * * @param entity The entity to be refreshed. */
void refresh(Object entity);
Refresh the entity instance state from the database.
Params:
  • entityName – The entityName for the entity to be refreshed.
  • entity – The entity to be refreshed.
/** * Refresh the entity instance state from the database. * * @param entityName The entityName for the entity to be refreshed. * @param entity The entity to be refreshed. */
void refresh(String entityName, Object entity);
Refresh the entity instance state from the database.
Params:
  • entity – The entity to be refreshed.
  • lockMode – The LockMode to be applied.
/** * Refresh the entity instance state from the database. * * @param entity The entity to be refreshed. * @param lockMode The LockMode to be applied. */
void refresh(Object entity, LockMode lockMode);
Refresh the entity instance state from the database.
Params:
  • entityName – The entityName for the entity to be refreshed.
  • entity – The entity to be refreshed.
  • lockMode – The LockMode to be applied.
/** * Refresh the entity instance state from the database. * * @param entityName The entityName for the entity to be refreshed. * @param entity The entity to be refreshed. * @param lockMode The LockMode to be applied. */
void refresh(String entityName, Object entity, LockMode lockMode);
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.
Deprecated:just missed when deprecating same method from Session
Returns:The connection associated with this stateless session
/** * Returns the current JDBC connection associated with this * instance.<br> * <br> * 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. * * @deprecated just missed when deprecating same method from {@link Session} * * @return The connection associated with this stateless session */
@Deprecated Connection connection(); }