Top Description Methods
org.hibernate

public Interface StatelessSession

extends SharedSessionContract, AutoCloseable, Closeable
Known Direct Implementers
org.hibernate.internal.StatelessSessionImpl
Imports
java.io.Closeable, .Serializable, java.sql.Connection, org.hibernate.query.NativeQuery

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 void
close()

Redeclares org.hibernate.SharedSessionContract.close, java.lang.AutoCloseable.close, java.io.Closeable.close.

Close the stateless session and release the JDBC connection.
public Connection

Returns:

The connection associated with this stateless session
connection
()

Deprecated just missed when deprecating same method from Session
Returns the current JDBC connection associated with this instance.
public NativeQuery<T>
createSQLQuery(String
The SQL query
queryString
)

Redeclares as abstract: org.hibernate.query.QueryProducer.createSQLQuery.

Deprecated as a consequence of NativeQuery being deprecated.
Create a NativeQuery instance 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
The name of the entity to retrieve
entityName
,
Serializable
The id of the entity to retrieve
id
)

Retrieve a row.

public Object

Returns:

a detached entity instance
get
(Class<T>
The class of the entity to retrieve
entityClass
,
Serializable
The id of the entity to retrieve
id
)

Retrieve a row.

public Object

Returns:

a detached entity instance
get
(String
The name of the entity to retrieve
entityName
,
Serializable
The id of the entity to retrieve
id
,
LockMode
The lock mode to apply to the entity
lockMode
)

Retrieve a row, obtaining the specified lock mode.

public Object

Returns:

a detached entity instance
get
(Class<T>
The class of the entity to retrieve
entityClass
,
Serializable
The id of the entity to retrieve
id
,
LockMode
The lock mode to apply to the entity
lockMode
)

Retrieve a row, obtaining the specified lock mode.

public Serializable

Returns:

The identifier of the inserted entity
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.

Inherited from org.hibernate.SharedSessionContract:
beginTransactioncreateCriteriacreateCriteriacreateCriteriacreateCriteriacreateQuerycreateStoredProcedureCallcreateStoredProcedureCallcreateStoredProcedureCalldoReturningWorkdoWorkgetJdbcBatchSizegetNamedProcedureCallgetNamedQuerygetTenantIdentifiergetTransactionisConnectedisOpensetJdbcBatchSize

Method Detail

closeback to summary
public void close()

Redeclares org.hibernate.SharedSessionContract.close, java.lang.AutoCloseable.close, java.io.Closeable.close.

Close the stateless session and release the JDBC connection.

connectionback to summary
public Connection connection()

Deprecated

just missed when deprecating same method from Session

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.

Returns:Connection

The connection associated with this stateless session

Annotations
@Deprecated
createSQLQueryback to summary
public NativeQuery<T> createSQLQuery(String queryString)

Redeclares as abstract: org.hibernate.query.QueryProducer.createSQLQuery.

Doc from org.hibernate.query.QueryProducer.createSQLQuery.

Deprecated

as a consequence of NativeQuery being deprecated. See corresponding docs for further information.

Create a NativeQuery instance for the given SQL query string.

Parameters
queryString:String

The SQL query

Returns:NativeQuery<T>

The query instance for manipulation and execution

Annotations
@Override
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.

Parameters
entityName:String

The name of the entity to retrieve

id:Serializable

The id of the entity to retrieve

Returns:Object

a detached entity instance

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

Retrieve a row.

Parameters
entityClass:Class<T>

The class of the entity to retrieve

id:Serializable

The id of the entity to retrieve

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.

Parameters
entityName:String

The name of the entity to retrieve

id:Serializable

The id of the entity to retrieve

lockMode:LockMode

The lock mode to apply to the entity

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.

Parameters
entityClass:Class<T>

The class of the entity to retrieve

id:Serializable

The id of the entity to retrieve

lockMode:LockMode

The lock mode to apply to the entity

Returns:Object

a detached entity instance

insertback to summary
public Serializable insert(Object entity)

Insert a row.

Parameters
entity:Object

a new transient instance

Returns:Serializable

The identifier of the inserted entity

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