Files
hibernate-demo/soft-delete/src/main/java/com/ankurm/softdelete/ArticleStamped.java
T

22 lines
755 B
Java

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; }
}