From 4ef7d81198bd2df5418834b2471058a69348c603 Mon Sep 17 00:00:00 2001 From: yulmam <70622601+yulmam@users.noreply.github.com> Date: Fri, 9 Aug 2024 13:37:50 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20timestamp=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/edufocus/edufocus/board/entity/vo/Board.java | 6 ++++-- .../java/com/edufocus/edufocus/board/entity/vo/Comment.java | 6 ++++-- .../java/com/edufocus/edufocus/report/entity/vo/Report.java | 5 +++-- .../com/edufocus/edufocus/report/entity/vo/ReportSet.java | 5 +++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Board.java b/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Board.java index 0f7d34a..bc05d56 100644 --- a/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Board.java +++ b/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Board.java @@ -8,6 +8,8 @@ import com.edufocus.edufocus.user.model.entity.vo.User; import com.fasterxml.jackson.annotation.JsonAutoDetect; import jakarta.persistence.*; import lombok.*; +import org.hibernate.annotations.CreationTimestamp; +import org.hibernate.annotations.UpdateTimestamp; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -41,11 +43,11 @@ public class Board { private int viewCount; @Column(columnDefinition = "TIMESTAMP") - @CreatedDate + @CreationTimestamp LocalDateTime createdAt; @Column(columnDefinition = "TIMESTAMP") - @LastModifiedDate + @UpdateTimestamp LocalDateTime modifiedAt; @ManyToOne(fetch = FetchType.LAZY) diff --git a/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Comment.java b/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Comment.java index 9887128..4928800 100644 --- a/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Comment.java +++ b/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Comment.java @@ -9,6 +9,8 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.NoArgsConstructor; import lombok.Setter; +import org.hibernate.annotations.CreationTimestamp; +import org.hibernate.annotations.UpdateTimestamp; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; @@ -29,11 +31,11 @@ public class Comment { private String content; @Column(columnDefinition = "TIMESTAMP") - @CreatedDate + @CreationTimestamp private LocalDateTime createdAt; @Column(columnDefinition = "TIMESTAMP") - @LastModifiedDate + @UpdateTimestamp private LocalDateTime modifiedAt; @ManyToOne diff --git a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java index 9205532..32a5b5c 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java @@ -6,6 +6,7 @@ import com.edufocus.edufocus.user.model.entity.vo.User; import com.fasterxml.jackson.annotation.JsonAutoDetect; import jakarta.persistence.*; import lombok.*; +import org.hibernate.annotations.CreationTimestamp; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -31,7 +32,7 @@ public class Report { private int correctCount; @Column(columnDefinition = "TIMESTAMP") - @CreatedDate + @CreationTimestamp private LocalDateTime testAt; private Long lectureId; @@ -48,7 +49,7 @@ public class Report { @JoinColumn(name = "reportset_id") private ReportSet reportSet; - @OneToMany(mappedBy = "report", cascade = CascadeType.ALL) + @OneToMany(mappedBy = "report", cascade = CascadeType.REMOVE) private List answers; public ReportResponse makeReportResponse(){ diff --git a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java index 7f8f691..d263393 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect; import jakarta.persistence.*; import lombok.*; import org.hibernate.annotations.ColumnDefault; +import org.hibernate.annotations.CreationTimestamp; import org.hibernate.annotations.GenericGenerator; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -35,10 +36,10 @@ public class ReportSet { private UUID id; @Column(columnDefinition = "TIMESTAMP") - @CreatedDate + @CreationTimestamp private LocalDateTime createAt; - @OneToMany(mappedBy = "reportSet", cascade = CascadeType.ALL) + @OneToMany(mappedBy = "reportSet", cascade = CascadeType.REMOVE) private List reports; @ManyToOne