4.4.5.4. Transaction Timeout
You can set a timeout in seconds for created transaction. When the timeout is exceeded, the transaction is interrupted and rolled back. Transaction timeout effectively limits the maximum duration of a database request.
When transactions are managed programmatically, the timeout is specified by passing TransactionParams
object to the Persistence.createTransaction()
method. For example:
Transaction tx = persistence.createTransaction(new TransactionParams().setTimeout(2));
In the case of declarative transactions management, timeout
parameter of the @Transactional
annotation can be used, for example:
@Transactional(timeout = 2)
public void someServiceMethod() {
...
The default timeout can be defined using the cuba.defaultQueryTimeoutSec application property.