Search code examples
javaspringspring-bootspring-data-jpaspring-data

Spring Data JPA - Exception thrown when using DeleteById with a non existing id


I am using a spring data JPA with a Postgresql db. I have an elementary table, a primary key (varchar) and some attributes. I have a repository and a service using this repository.

I am facing an issue when using deleteById or by using deleteAllById. Indeed, the method should ignore a non-existing id. But when I'm using one of those methods an exception is thrown EmptyResultDataAccessException.

I would like to know how to set jpa to ignore if an id doesn't exist in my table as explained in the doc of CrudRepository.

Thank you in advance for your answers


Solution

  • I think you are hit by https://github.com/spring-projects/spring-data-jpa/issues/2719

    Fixed in 3.0.2+