DocumentComment.java
package com.edtech.model;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.PrePersist;
import jakarta.persistence.Table;
import java.time.ZonedDateTime;
import java.util.UUID;
/** Javadoc. */
@Entity
@Table(name = "document_comments")
public class DocumentComment {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private UUID id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "document_id", nullable = false)
private Document document;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "author_id", nullable = false)
private User author;
@Column(nullable = false, columnDefinition = "TEXT")
private String content;
@Column(nullable = false)
private ZonedDateTime createdAt;
@PrePersist
protected void onCreate() {
this.createdAt = ZonedDateTime.now();
}
// Getters and Setters
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public Document getDocument() {
return document;
}
public void setDocument(Document document) {
this.document = document;
}
public User getAuthor() {
return author;
}
public void setAuthor(User author) {
this.author = author;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public ZonedDateTime getCreatedAt() {
return createdAt;
}
public void setCreatedAt(ZonedDateTime createdAt) {
this.createdAt = createdAt;
}
}