spring-projects / spring-data-jpa

Simplifies the development of creating a JPA-based data access layer.
https://spring.io/projects/spring-data-jpa/
Apache License 2.0
2.92k stars 1.39k forks source link

Missing `@Transactional` on `SimpleJpaRepository.delete(spec)` #3499

Closed gbrehmer closed 3 weeks ago

gbrehmer commented 3 weeks ago

Is there a reason that this delete method variant has no predefined @Transactional marker?

https://github.com/spring-projects/spring-data-jpa/blob/4387a31069f8b2b4b3b6a51d60e13b0ebcacbb05/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java#L479

Currently this breaks support (or needs additional boilerplate code) for the best practice of adding @Transactional(readOnly=true) at repository class level

mp911de commented 3 weeks ago

That's an oversight on our end, the method should be marked @Transactional.

quaff commented 3 weeks ago

@mp911de Please see https://github.com/spring-projects/spring-data-jpa/pull/3194 to decide if we need a test case to prevent such oversight.