I have a method:
@Transactional
@Override
public void createFile(final String number) {
try {
//code to save values
throw new Exception(number);
} catch(Exception e){
this.repository.save(e.getMessage());
}
}
In the method createFile there are many database save operations which needs to rollback when an error occurs. Catch needs to save the error message in the table.
How can i rollback the whole transaction in case of Exception but still do that save/update this.repository.save(e.getMessage()); on the database? could anyone help me sort this out? Thanks in advance.