I found the same issue as in this question: "Avoid saving data in spring data rest in handleBeforeSave"
And resolved it by creating a @Transactional(propagation = Propagation.REQUIRES_NEW) in the class that handles the save to the database, that is called by the handleBeforeSave class.
I want to understand why the handleBeforeSave of the RepositoryRestResource can't handle the rollback when a save is executed with a thrown exception?
I was expecting that the handleBeforeSave could handle the rollback of errors in the database.