advancedSoft Deletes — @SQLDelete, @SQLRestriction/@Where
What do @SQLDelete and @SQLRestriction (or @Where) each do, and why are both needed together?
@SQLDelete replaces the actual DELETE Hibernate would generate with a custom UPDATE (e.g., setting a deleted_at timestamp), so calling remove() performs a soft delete. @SQLRestriction/@Where automatically appends a filter excluding soft-deleted rows to every query Hibernate generates for that entity. Using only @SQLDelete still requires manually filtering soft-deleted rows in every other query; using only @SQLRestriction doesn't change what remove() actually does.
This is a Pro chapter
Sign in, then upgrade to Pro or Power to unlock this and the full Spring Ecosystem Mastery library.
What do @SQLDelete and @SQLRestriction (or @Where) each do, and why are both needed together?