public class TransactionHelper extends Object
Constructor and Description |
---|
TransactionHelper(SessionFactory sessionFactory) |
Modifier and Type | Method and Description |
---|---|
<T> T |
executeReadOnlyTransaction(SessionWork<T> sessionWork)
Execute the specified
sessionWork in a session configured
for read-only interactions with the database. |
<T> T |
executeReadWriteTransaction(SessionWork<T> sessionWork)
Execute the specified
sessionWork in a session configured
for read/write interactions with the database. |
<T> T |
executeReadWriteTransaction(SessionWork<T> sessionWork,
boolean readOnlyEntities) |
public TransactionHelper(SessionFactory sessionFactory)
public <T> T executeReadOnlyTransaction(SessionWork<T> sessionWork)
sessionWork
in a session configured
for read-only interactions with the database. This method should be
used for select queries.
In case of a transaction failure a retry is performed or not based on
the value defined by PASchedulerProperties.SCHEDULER_DB_TRANSACTION_MAXIMUM_RETRIES
.
T
- the result type of the session work.sessionWork
- the action to perform.public <T> T executeReadWriteTransaction(SessionWork<T> sessionWork)
sessionWork
in a session configured
for read/write interactions with the database. This method should be
used for insert, update, and delete queries. If select only is required,
then executeReadOnlyTransaction(SessionWork)
could be used.
In case of database error while executing the query, a rollback is
performed and a retry executed depending of the value associated to
the property PASchedulerProperties.SCHEDULER_DB_TRANSACTION_MAXIMUM_RETRIES
.
T
- the result type of the session work.sessionWork
- the action to perform.public <T> T executeReadWriteTransaction(SessionWork<T> sessionWork, boolean readOnlyEntities)