setRollbackOnly
setRollbackOnly is a method in the Java Transaction API (JTA) used to mark the current global transaction for rollback. It is available on transactional control interfaces such as javax.transaction.UserTransaction and javax.transaction.Transaction. Calling this method signals the transaction manager that the transaction must not be committed, typically in response to an error condition or business rule violation detected during transactional work.
Once setRollbackOnly has been invoked, any subsequent attempt to commit the transaction will result in a rollback
setRollbackOnly does not immediately revert changes; it marks the transaction as rollback-only and defers the rollback
Usage context: Common in enterprise Java components that participate in global transactions, such as EJBs or
Notes: Availability and exact behavior may vary by transaction manager and container; attempting to call setRollbackOnly
See also: UserTransaction, Transaction, RollbackException, Status.