Sobes.tech
Senior

Name the parameters of the @Transactional annotation.

sobes.tech AI

Answer from AI

The @Transactional annotation in Spring is used for transaction management and has several key parameters:

  • propagation — defines the behavior of the transaction when calling a method, such as REQUIRED, REQUIRES_NEW, SUPPORTS, etc.
  • isolation — the isolation level of the transaction, for example, READ_COMMITTED, SERIALIZABLE.
  • timeout — the maximum execution time of the transaction in seconds.
  • readOnly — indicates that the transaction is read-only, which can optimize database operations.
  • rollbackFor and noRollbackFor — exception classes for which the transaction should or should not be rolled back.

Example of usage:

@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED, timeout = 30, readOnly = false, rollbackFor = Exception.class)
public void updateData() {
    // business logic
}
Name the parameters of the @Transactional annotation… - sobes.tech