Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
[FIX]: 양방향 연관관계 설정, cascade ALL 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
LEEJaeHyeok97 committed Jan 17, 2024
1 parent 24bb61b commit 4173afd
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class CmaBookmark extends BaseEntity {
// 금융 뭐하지 id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "cma_id")
@OnDelete(action = OnDeleteAction.CASCADE)
private CMA cma;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class FinancialProductBookmark extends BaseEntity {
// 금융 뭐하지 id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "financial_product_id")
@OnDelete(action = OnDeleteAction.CASCADE)
private FinancialProduct financialProduct;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class NewsContentBookmark extends BaseEntity {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "news_content_id")
@OnDelete(action = OnDeleteAction.CASCADE)
private NewsContent newsContent;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class PolicyInfoBookmark extends BaseEntity {
// 금융 고마워 id
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "policy_info_id")
@OnDelete(action = OnDeleteAction.CASCADE)
private PolicyInfo policyInfo;

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public class PostBookmark extends BaseEntity {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "post_id")
@OnDelete(action = OnDeleteAction.CASCADE)
private Post post;

@Enumerated(EnumType.STRING)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.finfellows.domain.newscontent.domain;

import com.finfellows.domain.bookmark.domain.NewsContentBookmark;
import com.finfellows.domain.common.BaseEntity;

import com.finfellows.domain.post.domain.ContentType;
Expand All @@ -11,6 +12,9 @@
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;

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

@Entity
@Table(name="NewsContent")
@NoArgsConstructor
Expand All @@ -36,6 +40,9 @@ public class NewsContent extends BaseEntity {
@Column(name="contentType")
private ContentType contentType;

@OneToMany(mappedBy = "newsContent", cascade = CascadeType.ALL)
private List<NewsContentBookmark> newsContentBookmarkList = new ArrayList<>();

@Builder
public NewsContent(Post post, String title, String content){
this.post=post;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.finfellows.domain.policyinfo.domain;

import com.finfellows.domain.bookmark.domain.PolicyInfoBookmark;
import com.finfellows.domain.common.BaseEntity;
import com.finfellows.domain.policyinfo.dto.PolicyUpdateReq;
import jakarta.persistence.*;
Expand All @@ -9,6 +10,9 @@
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Where;

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

@Entity
@Table(name = "PolicyInfo")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand Down Expand Up @@ -57,6 +61,9 @@ public class PolicyInfo extends BaseEntity {

private String pstnPaprCn;

@OneToMany(mappedBy = "policyInfo", cascade = CascadeType.ALL)
private List<PolicyInfoBookmark> policyInfoBookmarkList = new ArrayList<>();

public void updatePolicyInfo(PolicyUpdateReq policyUpdateReq) {
this.polyBizSjNm = policyUpdateReq.getPolyBizSjNm();
this.polyItcnCn = policyUpdateReq.getPolyItcnCn();
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/finfellows/domain/product/domain/CMA.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.finfellows.domain.product.domain;

import com.finfellows.domain.bookmark.domain.CmaBookmark;
import com.finfellows.domain.common.BaseEntity;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

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

@Entity
@Table(name = "CMA")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
Expand Down Expand Up @@ -48,6 +52,9 @@ public class CMA extends BaseEntity {
@Column(name="deposit_protection")
private String depositProtection;

@OneToMany(mappedBy = "cma", cascade = CascadeType.ALL)
private List<CmaBookmark> cmaBookmarkList = new ArrayList<>();

@Builder
public CMA(String bankName, String productName, String cmaType, String disclosureMonth, String maturityInterestRate, String specialCondition, String joinWay, String etcNote, String productUrl, String depositProtection) {
this.bankName = bankName;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.finfellows.domain.product.domain;

import com.finfellows.domain.bookmark.domain.FinancialProductBookmark;
import com.finfellows.domain.common.BaseEntity;
import jakarta.persistence.*;
import lombok.AccessLevel;
Expand All @@ -10,6 +11,7 @@

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Entity
Expand Down Expand Up @@ -75,6 +77,9 @@ public class FinancialProduct extends BaseEntity {
@OneToMany(mappedBy = "financialProduct", fetch = FetchType.LAZY)
private List<FinancialProductOption> financialProductOption;

@OneToMany(mappedBy = "financialProduct", cascade = CascadeType.ALL)
private List<FinancialProductBookmark> financialProductBookmarkList = new ArrayList<>();

@Builder
public FinancialProduct(String financialCompanyNo, String financialProductCode, String disclosureMonth, String bankName, String productName, String joinWay, String maturityInterestRate, String specialCondition, Integer joinDeny, String joinMember, String etcNote, Integer maxLimit, LocalDate disclosureStartDay, LocalDate disclosureEndDay, LocalDateTime financialCompanySubmissionDay, FinancialProductType financialProductType, List<FinancialProductOption> financialProductOption) {
this.financialCompanyNo = financialCompanyNo;
Expand Down

0 comments on commit 4173afd

Please sign in to comment.