2

I want to modify the repository.deleteAll() and repository.delete() so it don't delete everything, but just set active column to false.

Is this achievable for all my repository at once ?

Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204
  • 1
    I really wouldn't do that. That would radically change the contract of these two methods. Why don't you just add two separate methods, with their own javadoc, their own contract, and their own implementation? http://docs.spring.io/spring-data/jpa/docs/1.7.2.RELEASE/reference/html/#repositories.custom-behaviour-for-all-repositories – JB Nizet Dec 25 '16 at 12:26
  • Additional note: why do you even need a repository method to do that? How about just `myEntity.setActive(false)`? – JB Nizet Dec 25 '16 at 12:28
  • Possible duplicate of [Spring Data: Override save method](http://stackoverflow.com/questions/13036159/spring-data-override-save-method) – Jens Schauder Dec 25 '16 at 16:02

1 Answers1

2

I think you mean so-called 'soft delete'... There is one of implementations: Handling soft-deletes with Spring JPA

And this issue is still open for Spring Data JPA: https://jira.spring.io/browse/DATAJPA-307

Community
  • 1
  • 1
Cepr0
  • 28,144
  • 8
  • 75
  • 101