JPA deleteInBatch가 Deprecated 된 이유

@ZungTa · 2023-07-21 금요일 · 1 min read

Spring Boot JPA에서 deleteInBatch 메서드를 사용하려는데 deprecated라고 표시되었고 deleteAllInBatch 메서드를 사용하라고 표시된다.

delete-in-batch-deprecated

delete-in-batch-deprecated

이유를 알아보았다.

jpa-doc-delete-in-batch

jpa-doc-delete-in-batch

Deletes the given entities in a batch which means it will create a single query. This kind of operation leaves JPAs first level cache and the database out of sync. Consider flushing the EntityManager before calling this method.

JpaRepository.java 코드를 살펴보니 deleteInBatch 호출 시 내부적으로 deleteAllInBatch를 호출한다.

아마 메서드 행위의 용어를 명확히 하기 위해서 변경하는 것 같다.

jpa-repository-code

jpa-repository-code

@ZungTa
I'm a backend developer
© ZungTa Devlog, Built with Gatsby