Add soft-delete module: @SoftDelete (DELETED/ACTIVE/TIMESTAMP) vs @SQLDelete + @SQLRestriction on Hibernate 7.4.14.Final, H2 and PostgreSQL 17

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b7rnC7jppGGdHGESvy
This commit is contained in:
2026-10-28 18:22:03 +00:00
co-authored by Claude Sonnet 5.5
parent aea104f021
commit c9faf35e61
43 changed files with 2084 additions and 0 deletions
@@ -0,0 +1,25 @@
package com.ankurm.softdelete;
import jakarta.persistence.*;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLRestriction;
/** The hand-rolled recipe that predates {@code @SoftDelete}: a mapped column, an UPDATE instead of DELETE, a WHERE on every read. */
@Entity
@Table(name = "article_manual")
@SQLDelete(sql = "update article_manual set deleted = true where id = ?")
@SQLRestriction("deleted = false")
public class ArticleManual {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String title;
@Column(nullable = false)
private boolean deleted;
protected ArticleManual() {}
public ArticleManual(String title) { this.title = title; }
public Long getId() { return id; }
public String getTitle() { return title; }
public boolean isDeleted() { return deleted; }
}