Package org.hibernate
Interface StatelessSession
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
,QueryProducer
,java.io.Serializable
,SharedSessionContract
public interface StatelessSession extends SharedSessionContract, java.lang.AutoCloseable, java.io.Closeable
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.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
close()
Close the stateless session and release the JDBC connection.java.sql.Connection
connection()
Deprecated.just missed when deprecating same method fromSession
NativeQuery
createSQLQuery(java.lang.String queryString)
Create aNativeQuery
instance for the given SQL query string.void
delete(java.lang.Object entity)
Delete a row.void
delete(java.lang.String entityName, java.lang.Object entity)
Delete a row.java.lang.Object
get(java.lang.Class entityClass, java.io.Serializable id)
Retrieve a row.java.lang.Object
get(java.lang.Class entityClass, java.io.Serializable id, LockMode lockMode)
Retrieve a row, obtaining the specified lock mode.java.lang.Object
get(java.lang.String entityName, java.io.Serializable id)
Retrieve a row.java.lang.Object
get(java.lang.String entityName, java.io.Serializable id, LockMode lockMode)
Retrieve a row, obtaining the specified lock mode.java.io.Serializable
insert(java.lang.Object entity)
Insert a row.java.io.Serializable
insert(java.lang.String entityName, java.lang.Object entity)
Insert a row.void
refresh(java.lang.Object entity)
Refresh the entity instance state from the database.void
refresh(java.lang.Object entity, LockMode lockMode)
Refresh the entity instance state from the database.void
refresh(java.lang.String entityName, java.lang.Object entity)
Refresh the entity instance state from the database.void
refresh(java.lang.String entityName, java.lang.Object entity, LockMode lockMode)
Refresh the entity instance state from the database.void
update(java.lang.Object entity)
Update a row.void
update(java.lang.String entityName, java.lang.Object entity)
Update a row.-
Methods inherited from interface org.hibernate.query.QueryProducer
createNamedQuery, createNamedQuery, createNativeQuery, createNativeQuery, createNativeQuery, createQuery, getNamedNativeQuery, getNamedSQLQuery
-
Methods inherited from interface org.hibernate.SharedSessionContract
beginTransaction, createCriteria, createCriteria, createCriteria, createCriteria, createQuery, createStoredProcedureCall, createStoredProcedureCall, createStoredProcedureCall, getJdbcBatchSize, getNamedProcedureCall, getNamedQuery, getTenantIdentifier, getTransaction, isConnected, isOpen, setJdbcBatchSize
-
-
-
-
Method Detail
-
close
void close()
Close the stateless session and release the JDBC connection.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceSharedSessionContract
-
insert
java.io.Serializable insert(java.lang.Object entity)
Insert a row.- Parameters:
entity
- a new transient instance- Returns:
- The identifier of the inserted entity
-
insert
java.io.Serializable insert(java.lang.String entityName, java.lang.Object entity)
Insert a row.- Parameters:
entityName
- The entityName for the entity to be insertedentity
- a new transient instance- Returns:
- the identifier of the instance
-
update
void update(java.lang.Object entity)
Update a row.- Parameters:
entity
- a detached entity instance
-
update
void update(java.lang.String entityName, java.lang.Object entity)
Update a row.- Parameters:
entityName
- The entityName for the entity to be updatedentity
- a detached entity instance
-
delete
void delete(java.lang.Object entity)
Delete a row.- Parameters:
entity
- a detached entity instance
-
delete
void delete(java.lang.String entityName, java.lang.Object entity)
Delete a row.- Parameters:
entityName
- The entityName for the entity to be deletedentity
- a detached entity instance
-
get
java.lang.Object get(java.lang.String entityName, java.io.Serializable id)
Retrieve a row.- Parameters:
entityName
- The name of the entity to retrieveid
- The id of the entity to retrieve- Returns:
- a detached entity instance
-
get
java.lang.Object get(java.lang.Class entityClass, java.io.Serializable id)
Retrieve a row.- Parameters:
entityClass
- The class of the entity to retrieveid
- The id of the entity to retrieve- Returns:
- a detached entity instance
-
get
java.lang.Object get(java.lang.String entityName, java.io.Serializable id, LockMode lockMode)
Retrieve a row, obtaining the specified lock mode.- Parameters:
entityName
- The name of the entity to retrieveid
- The id of the entity to retrievelockMode
- The lock mode to apply to the entity- Returns:
- a detached entity instance
-
get
java.lang.Object get(java.lang.Class entityClass, java.io.Serializable id, LockMode lockMode)
Retrieve a row, obtaining the specified lock mode.- Parameters:
entityClass
- The class of the entity to retrieveid
- The id of the entity to retrievelockMode
- The lock mode to apply to the entity- Returns:
- a detached entity instance
-
refresh
void refresh(java.lang.Object entity)
Refresh the entity instance state from the database.- Parameters:
entity
- The entity to be refreshed.
-
refresh
void refresh(java.lang.String entityName, java.lang.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.
-
refresh
void refresh(java.lang.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.
-
refresh
void refresh(java.lang.String entityName, java.lang.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.
-
connection
@Deprecated java.sql.Connection connection()
Deprecated.just missed when deprecating same method fromSession
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:
- The connection associated with this stateless session
-
createSQLQuery
NativeQuery createSQLQuery(java.lang.String queryString)
Description copied from interface:QueryProducer
Create aNativeQuery
instance for the given SQL query string.- Specified by:
createSQLQuery
in interfaceQueryProducer
- Parameters:
queryString
- The SQL query- Returns:
- The query instance for manipulation and execution
-
-