Rollback transaction - Update entity


When an exception occurs, I must update an entity in database. Can I update this entity in try catch ?

}catch(Exception ex){

Should I have create a new service annotated @Transactional(propagation = Propagation.REQUIRES_NEW) ?

On rollback, using REQUIRES_NEW will force the start of a new transaction, and I can update this entity. Do you confirm ?

Thanks by advance.

Yes, you have to do the update in a new transaction if you want to use this kind of pattern.