In the @Transactional annotation @Transactional you can specify whether the transaction should be rolled back due to this exception using the noRollbackForClassName attribute. You can do it similar to this.
@Service @Transactional(noRollbackForClassName = "java.lang.Exception") public class YourClass { ... }
However, note that simply saying noRollbackForClassName = "java.lang.Exception" means that it will not roll back for any Exception (or its subclasses), therefore, this is not good practice.
What you need to do is figure out which exception is actually thrown first (maybe by printing e.getClass().getName() ), and then set this class name to noRollbackForClassName.
Reasonable, this is because if an exception is thrown when you try to delete (), the current transaction is automatically marked as rollback only, and if it is attempted, the exception that you see will be thrown. The data transfer method is to explicitly indicate that this particular exception should not cause a rollback.
source share