Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[refactor] 연관 관계 수정 #76

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import mju.iphak.maru_egg.answer.domain.Answer;
import mju.iphak.maru_egg.common.entity.BaseEntity;

@Getter
Expand Down Expand Up @@ -39,6 +41,9 @@ public class Question extends BaseEntity {
@ColumnDefault("false")
private boolean isChecked;

@OneToOne(mappedBy = "question", orphanRemoval = true)
private Answer answer;

public String getDateInformation() {
return "생성일자: %s, 마지막 DB 갱신일자: %s".formatted(this.getCreatedAt(), this.getUpdatedAt());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class AnswerRepositoryTest extends RepositoryTest {

@BeforeEach
public void setUp() throws Exception {
Question question = new Question("테스트 질문입니다.", "테스트 질문", QuestionType.JEONGSI,
QuestionCategory.ADMISSION_GUIDELINE, 0, false);
Question question = Question.of("테스트 질문입니다.", "테스트 질문", QuestionType.JEONGSI,
QuestionCategory.ADMISSION_GUIDELINE);
questionRepository.save(question);
Answer answer = Answer.of(question, "테스트 답변입니다.");
answerRepository.save(answer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class QuestionRepositoryTest extends RepositoryTest {

@BeforeEach
public void setUp() throws Exception {
question = new Question("테스트 질문 예시 예시입니다.", "테스트 질문 예시", QuestionType.SUSI,
QuestionCategory.ADMISSION_GUIDELINE, 0, false);
question = Question.of("테스트 질문 예시 예시입니다.", "테스트 질문 예시", QuestionType.SUSI,
QuestionCategory.ADMISSION_GUIDELINE);
questionRepository.save(question);
Question additionalQuestion1 = Question.of("추가1 테스트 질문 예시입니다.", "추가 테스트 질문 예시", QuestionType.SUSI,
QuestionCategory.ADMISSION_GUIDELINE);
Expand Down
Loading