Viewed in opposition to Session, the StatelessSession is
a whole competing programming model, one preferred by some developers
for its simplicity and somewhat lower level of abstraction. But the two
kinds of session are not enemies, and may comfortably coexist in a single
program.
A stateless session comes some with designed-in limitations:
Furthermore:
Stateless sessions are vulnerable to data aliasing effects, due to the lack of a first-level cache.
On the other hand, for certain kinds of transactions, a stateless session may perform slightly faster than a stateful session.
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Redeclares org. |
| public void | |
| public void | |
| public void | |
| public Object | |
| public <T> T | |
| public Object | |
| public <T> T | |
| public <T> T | Returns: a detached entity instanceThe graph, GraphSemantic EntityGrapha graphSemantic, Object GraphSemantic specifying
how the graph should be interpretedThe id of the entity to retrieve id)Retrieve a row, fetching associations specified by the
given |
| public <T> T | Returns: a detached entity instanceThe graph, GraphSemantic EntityGrapha graphSemantic, Object GraphSemantic specifying
how the graph should be interpretedThe id of the entity to retrieve id, LockMode The lock mode to apply to the entity lockMode)Retrieve a row, fetching associations specified by the
given |
| public Object | |
| public Object | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void |
| close | back to summary |
|---|---|
| public void close() Redeclares org. Close the stateless session and release the JDBC connection. | |
| delete | back to summary |
|---|---|
| public void delete(Object entity) Delete a row.
| |
| delete | back to summary |
|---|---|
| public void delete(String entityName, Object entity) Delete a row. | |
| fetch | back to summary |
|---|---|
| public 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.
| |
| get | back to summary |
|---|---|
| public Object get(String entityName, Object id) Retrieve a row. | |
| get | back to summary |
|---|---|
| public <T> T get(Class<T> entityClass, Object id) Retrieve a row. | |
| get | back to summary |
|---|---|
| public Object get(String entityName, Object id, LockMode lockMode) Retrieve a row, obtaining the specified lock mode. | |
| get | back to summary |
|---|---|
| public <T> T get(Class<T> entityClass, Object id, LockMode lockMode) Retrieve a row, obtaining the specified lock mode. | |
| get | back to summary |
|---|---|
| public <T> T get(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id) Retrieve a row, fetching associations specified by the
given
| |
| get | back to summary |
|---|---|
| public <T> T get(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id, LockMode lockMode) Retrieve a row, fetching associations specified by the
given
| |
| insert | back to summary |
|---|---|
| public Object insert(Object entity) Insert a row. | |
| insert | back to summary |
|---|---|
| public Object insert(String entityName, Object entity) Insert a row. | |
| refresh | back to summary |
|---|---|
| public void refresh(Object entity) Refresh the entity instance state from the database.
| |
| refresh | back to summary |
|---|---|
| public void refresh(String entityName, Object entity) Refresh the entity instance state from the database. | |
| refresh | back to summary |
|---|---|
| public void refresh(Object entity, LockMode lockMode) Refresh the entity instance state from the database. | |
| refresh | back to summary |
|---|---|
| public void refresh(String entityName, Object entity, LockMode lockMode) Refresh the entity instance state from the database. | |
| update | back to summary |
|---|---|
| public void update(Object entity) Update a row.
| |
| update | back to summary |
|---|---|
| public void update(String entityName, Object entity) Update a row. | |
| upsert | back to summary |
|---|---|
| public void upsert(Object entity) Use a SQL
| |
| upsert | back to summary |
|---|---|
| public void upsert(String entityName, Object entity) Use a SQL
| |