Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

refactor: 북마크 cascade 수정 #337

Merged
merged 3 commits into from
Jun 30, 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 @@ -34,11 +34,11 @@ public class Bookmark extends BaseEntity {
@Column(name = "bookmark_id")
private Long id;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "organization_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
private Organization organization;

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "target_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
private Organization target;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package com.sponus.coredomain.domain.organization;

import java.util.ArrayList;
import java.util.List;

import com.sponus.coredomain.domain.bookmark.Bookmark;
import com.sponus.coredomain.domain.common.BaseEntity;
import com.sponus.coredomain.domain.organization.enums.OrganizationType;
import com.sponus.coredomain.domain.organization.enums.ProfileStatus;
import com.sponus.coredomain.domain.organization.enums.Role;
import com.sponus.coredomain.domain.portfolio.PortfolioImage;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.DiscriminatorColumn;
import jakarta.persistence.Entity;
Expand All @@ -15,6 +21,7 @@
import jakarta.persistence.Id;
import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
Expand Down Expand Up @@ -75,6 +82,10 @@ public class Organization extends BaseEntity {
@Column(name = "is_deleted")
private boolean isDeleted;

@Builder.Default
@OneToMany(cascade = {CascadeType.ALL})
private List<Bookmark> bookmarks = new ArrayList<>();

protected Organization(
String name,
String email,
Expand Down
Loading