feat: cascade 설정
This commit is contained in:
parent
5bc56fc2a7
commit
4d479d702e
@ -64,10 +64,10 @@ public class Board {
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
private Lecture lecture;
|
||||
|
||||
@OneToMany(mappedBy = "board", cascade = CascadeType.ALL)
|
||||
@OneToMany(mappedBy = "board")
|
||||
private List<Comment> comments;
|
||||
|
||||
public ResponseBoardSummaryDto makeSummaryDto(){
|
||||
public ResponseBoardSummaryDto makeSummaryDto() {
|
||||
return ResponseBoardSummaryDto.builder()
|
||||
.id(id)
|
||||
.title(title)
|
||||
@ -76,7 +76,7 @@ public class Board {
|
||||
.build();
|
||||
}
|
||||
|
||||
public ResponseBoardDetailDto makeDetailDto(long userId){
|
||||
public ResponseBoardDetailDto makeDetailDto(long userId) {
|
||||
return ResponseBoardDetailDto.builder()
|
||||
.id(id)
|
||||
.name(user.getName())
|
||||
|
@ -10,6 +10,8 @@ import lombok.Builder;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.data.annotation.LastModifiedDate;
|
||||
@ -46,6 +48,7 @@ public class Comment {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "board_id")
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
Board board;
|
||||
|
||||
public ResponseCommentDto makeCommentDto(long userId) {
|
||||
|
@ -7,6 +7,8 @@ import com.edufocus.edufocus.report.entity.vo.ReportSet;
|
||||
import com.edufocus.edufocus.user.model.entity.vo.User;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.OnDelete;
|
||||
import org.hibernate.annotations.OnDeleteAction;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -22,22 +24,23 @@ public class Registration {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private long id;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
@ManyToOne
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
@JoinColumn(name = "lecture_id")
|
||||
private Lecture lecture;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private RegistrationStatus status;
|
||||
|
||||
public boolean isAccepted(){
|
||||
public boolean isAccepted() {
|
||||
return status == RegistrationStatus.ACCEPTED;
|
||||
}
|
||||
|
||||
public Report makeReport(ReportSet reportSet, QuizSet quizSet, long lectureId){
|
||||
public Report makeReport(ReportSet reportSet, QuizSet quizSet, long lectureId) {
|
||||
return Report.builder()
|
||||
.allCount(0)
|
||||
.correctCount(-1)
|
||||
|
@ -21,7 +21,7 @@ spring.datasource.username=${USER_NAME}
|
||||
spring.datasource.password=${USER_PASSWORD}
|
||||
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
|
||||
spring.jpa.database=mysql
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.hibernate.ddl-auto=create
|
||||
spring.jpa.show-sql=true
|
||||
spring.jpa.properties.hibernate.jdbc.time_zone=Asia/Seoul
|
||||
management.endpoints.web.exposure.include=health,info
|
||||
|
Loading…
Reference in New Issue
Block a user