Package org.hibernate
Interface StatelessSession
-
- All Superinterfaces:
AutoCloseable
,Closeable
,QueryProducer
,Serializable
,SharedSessionContract
- All Known Implementing Classes:
StatelessSessionImpl
public interface StatelessSession extends SharedSessionContract
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 Modifier and Type Method Description void
close()
Close the stateless session and release the JDBC connection.void
delete(Object entity)
Delete a row.void
delete(String entityName, Object entity)
Delete a row.void
fetch(Object association)
Fetch an association that's configured for lazy loading.<T> T
get(Class<T> entityClass, Object id)
Retrieve a row.<T> T
get(Class<T> entityClass, Object id, LockMode lockMode)
Retrieve a row, obtaining the specified lock mode.Object
get(String entityName, Object id)
Retrieve a row.Object
get(String entityName, Object id, LockMode lockMode)
Retrieve a row, obtaining the specified lock mode.Object
insert(Object entity)
Insert a row.Object
insert(String entityName, Object entity)
Insert a row.void
refresh(Object entity)
Refresh the entity instance state from the database.void
refresh(Object entity, LockMode lockMode)
Refresh the entity instance state from the database.void
refresh(String entityName, Object entity)
Refresh the entity instance state from the database.void
refresh(String entityName, Object entity, LockMode lockMode)
Refresh the entity instance state from the database.void
update(Object entity)
Update a row.void
update(String entityName, Object entity)
Update a row.-
Methods inherited from interface org.hibernate.query.QueryProducer
createMutationQuery, createMutationQuery, createMutationQuery, createMutationQuery, createNamedMutationQuery, createNamedQuery, createNamedQuery, createNamedSelectionQuery, createNamedSelectionQuery, createNativeMutationQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createNativeQuery, createQuery, createQuery, createQuery, createQuery, createQuery, createSelectionQuery, createSelectionQuery, createSelectionQuery, getNamedNativeQuery, getNamedNativeQuery, getNamedQuery
-
Methods inherited from interface org.hibernate.SharedSessionContract
beginTransaction, createNamedStoredProcedureQuery, createStoredProcedureCall, createStoredProcedureCall, createStoredProcedureCall, createStoredProcedureQuery, createStoredProcedureQuery, createStoredProcedureQuery, doReturningWork, doWork, getCriteriaBuilder, getJdbcBatchSize, getNamedProcedureCall, getTenantIdentifier, getTransaction, isConnected, isOpen, setJdbcBatchSize
-
-
-
-
Method Detail
-
close
void close()
Close the stateless session and release the JDBC connection.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceSharedSessionContract
-
insert
Object insert(Object entity)
Insert a row.- Parameters:
entity
- a new transient instance- Returns:
- The identifier of the inserted entity
-
insert
Object insert(String entityName, 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(Object entity)
Update a row.- Parameters:
entity
- a detached entity instance
-
update
void update(String entityName, Object entity)
Update a row.- Parameters:
entityName
- The entityName for the entity to be updatedentity
- a detached entity instance
-
delete
void delete(Object entity)
Delete a row.- Parameters:
entity
- a detached entity instance
-
delete
void delete(String entityName, Object entity)
Delete a row.- Parameters:
entityName
- The entityName for the entity to be deletedentity
- a detached entity instance
-
get
Object get(String entityName, Object 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
<T> T get(Class<T> entityClass, Object 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
Object get(String entityName, Object 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
<T> T get(Class<T> entityClass, Object 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(Object entity)
Refresh the entity instance state from the database.- Parameters:
entity
- The entity to be refreshed.
-
refresh
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.
-
refresh
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.
-
refresh
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.
-
fetch
void fetch(Object association)
Fetch an association that's configured for lazy loading.Warning: this operation in a stateless session is quite sensitive to data aliasing effects and should be used with great care.
- Parameters:
association
- a lazy-loaded association- See Also:
Hibernate.initialize(Object)
-
-