spring-data-r2dbc icon indicating copy to clipboard operation
spring-data-r2dbc copied to clipboard

Add support for soft deletes

Open eduanb opened this issue 3 years ago • 2 comments

With Hibernate and Spring Data JPA you can do a soft delete like this:

@SQLDelete(sql = "UPDATE user SET deleted = true WHERE id = ?", check = ResultCheckStyle.COUNT)
@Where(clause = "deleted = false")
class User {
 ...
}

Now when you do a delete from the repository it will just set deleted =true and with every select, it adds deleted = false. Similar functionality in Spring Data R2DBC would be very useful.

eduanb avatar Sep 15 '21 07:09 eduanb

For the time being, we do not support soft deletes as we do not have a consistent design across all store modules how removal or retrieval should be working. For the time being, please solve this issue within your application by e.g. providing a custom repository implementation.

See also spring-projects/spring-data-jpa#676

mp911de avatar Sep 16 '21 06:09 mp911de

Zero is used for undeleted and timestamp is used for deleted.

yangwenliang123 avatar Sep 07 '22 09:09 yangwenliang123