Fix default creation timestamps

This commit is contained in:
Tim
2025-07-09 13:50:16 +08:00
parent 90e3129e86
commit 36fa4ea570
4 changed files with 16 additions and 22 deletions

View File

@@ -4,6 +4,7 @@ import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import java.time.LocalDateTime;
@@ -42,11 +43,8 @@ public class Notification {
@Column(name = "is_read", nullable = false)
private boolean read = false;
@Column(nullable = false)
@CreationTimestamp
@Column(nullable = false, updatable = false,
columnDefinition = "DATETIME(6) DEFAULT CURRENT_TIMESTAMP(6)")
private LocalDateTime createdAt;
@PrePersist
protected void onCreate() {
this.createdAt = LocalDateTime.now();
}
}