Adin Fathi

28

January
As spring beans managed by spring to manage rollback don't use try catch ,however if using try catch on service level ,spring throwing commit managed by your self so you should call aspect rollback to get rollback behavior ..

spring @transactional rollback exception

Default value of rollback is register on Error Exception but when u register try{}catch{} manually it overriding the error, so in this case use

catch {
        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
      }


to do it manually or remove try catch

also you may register exception type in transactional annotation such:

 

@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)

Reference: -

your comment sent successfully and will show after approved by site administration .

Be The First One Adds a Comment