Skip to content

Commit

Permalink
hotfix: revise entity OneToOne mapping to ManyToOne
Browse files Browse the repository at this point in the history
  • Loading branch information
chock-cho committed Jan 11, 2025
1 parent 01dbe0a commit a235cbd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ExperimentPostEntity(
@Column(name = "experiment_post_id")
val id: Long,

@OneToOne(fetch = FetchType.LAZY)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
val member: MemberEntity,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.dobby.backend.domain.model.member.Member
import com.dobby.backend.infrastructure.database.entity.enum.MemberStatus
import com.dobby.backend.infrastructure.database.entity.enum.ProviderType
import com.dobby.backend.infrastructure.database.entity.enum.RoleType
import com.dobby.backend.infrastructure.database.entity.experiment.ExperimentPostEntity
import jakarta.persistence.*

@Entity
Expand Down Expand Up @@ -35,7 +36,11 @@ class MemberEntity(

@Column(name = "name", length = 10, nullable = true)
val name: String,
) : AuditingEntity() {

@OneToMany(mappedBy = "member", cascade = [CascadeType.ALL], orphanRemoval = true)
val experimentPosts: List<ExperimentPostEntity> = mutableListOf(),

) : AuditingEntity() {

fun toDomain() = Member(
id = id,
Expand Down

0 comments on commit a235cbd

Please sign in to comment.