Skip to content

Commit

Permalink
Fix: Member Entity OnetoMany 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
adorableco committed Sep 10, 2024
1 parent 0850ff1 commit 3ac576a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 15 additions & 0 deletions src/main/kotlin/com/swm_standard/phote/entity/Member.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.swm_standard.phote.entity

import jakarta.persistence.CascadeType
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.EnumType
import jakarta.persistence.Enumerated
import jakarta.persistence.Id
import jakarta.persistence.OneToMany
import org.hibernate.annotations.SQLDelete
import org.hibernate.annotations.SQLRestriction
import java.util.UUID

@Entity
@SQLDelete(sql = "UPDATE question_set SET deleted_at = NOW() WHERE question_set_id = ?")
@SQLRestriction("deleted_at is NULL")
data class Member(
val name: String,
val email: String,
Expand All @@ -18,4 +24,13 @@ data class Member(
@Id
@Column(name = "member_uuid", nullable = false, unique = true)
val id: UUID = UUID.randomUUID()

@OneToMany(mappedBy = "member", cascade = [(CascadeType.REMOVE)])
val questions: List<Question> = emptyList()

@OneToMany(mappedBy = "member", cascade = [(CascadeType.REMOVE)])
val workbooks: List<Workbook> = emptyList()

@OneToMany(mappedBy = "member", cascade = [(CascadeType.REMOVE)])
val exams: List<Exam> = emptyList()
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ class MemberService(
) {
fun deleteMember(memberId: UUID): UUID {
memberRepository.deleteById(memberId)
if (memberRepository.existsById(memberId)) {
throw IllegalStateException()
}

return memberId
}
Expand Down

0 comments on commit 3ac576a

Please sign in to comment.