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:
@@ -0,0 +1,21 @@
|
||||
package com.ankurm.softdelete;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import org.hibernate.annotations.SoftDelete;
|
||||
import org.hibernate.annotations.SoftDeleteType;
|
||||
|
||||
/** {@code SoftDeleteType.TIMESTAMP}: a nullable timestamp column; NULL = alive, a value = when it was removed. */
|
||||
@Entity
|
||||
@Table(name = "article_stamped")
|
||||
@SoftDelete(strategy = SoftDeleteType.TIMESTAMP, columnName = "deleted_at", comment = "NULL while the row is alive")
|
||||
public class ArticleStamped {
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private String title;
|
||||
|
||||
protected ArticleStamped() {}
|
||||
public ArticleStamped(String title) { this.title = title; }
|
||||
|
||||
public Long getId() { return id; }
|
||||
public String getTitle() { return title; }
|
||||
}
|
||||
Reference in New Issue
Block a user