Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b7rnC7jppGGdHGESvy
26 lines
871 B
Java
26 lines
871 B
Java
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; }
|
|
}
|