Skip to content

Commit

Permalink
๐Ÿ› Fix[#2]: CASCADE ๋ฐ˜์˜
Browse files Browse the repository at this point in the history
  • Loading branch information
kduoh99 committed Nov 23, 2024
1 parent ad11637 commit c5708a3
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/groom/swipo/domain/payment/entity/Pay.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public class Pay extends BaseEntity {
private Integer totalPay;

// ์œ ์ € id
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "user_id")
private User user;

// ํŽ˜์ด ๋‚ด์—ญ
@OneToMany(mappedBy = "pay", cascade = CascadeType.PERSIST)
@OneToMany(mappedBy = "pay", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Paylist> paylists = new ArrayList<>();

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class Card extends BaseEntity {
private User user;

// ์นด๋“œ ์ด์šฉ๋‚ด์—ญ
@OneToMany(mappedBy = "card", cascade = CascadeType.PERSIST)
@OneToMany(mappedBy = "card", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Cardlist> cardlists = new ArrayList<>();

@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public class Cardlist extends BaseEntity {
private Store store;

@Builder
private Cardlist(long value) {
private Cardlist(long value, Card card, Store store) {
this.value = value;
this.card = card;
this.store = store;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,14 @@ public class MyPiece extends BaseEntity {
private Store store;

@Builder
private MyPiece(Boolean isDeleted) {
private MyPiece(Boolean isDeleted, User user, Piece piece, Store store) {
this.isDeleted = isDeleted;
this.user = user;
this.piece = piece;
this.store = store;
}

public void setIsDeleted(boolean isDeleted) {
this.isDeleted = isDeleted;
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/com/groom/swipo/domain/point/entity/Piece.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public class Piece {
private String name;

// ๋‚ด ์กฐ๊ฐ
@OneToMany(mappedBy = "piece", cascade = CascadeType.PERSIST)
@OneToMany(mappedBy = "piece", cascade = CascadeType.ALL, orphanRemoval = true)
private List<MyPiece> myPieces = new ArrayList<>();

@Builder
private Piece(String name) {
this.name = name;
}
}
}
15 changes: 8 additions & 7 deletions src/main/java/com/groom/swipo/domain/store/entity/Store.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,38 +63,39 @@ public class Store extends BaseEntity {

// ์—ฐ๊ด€๊ด€๊ณ„
// ํŽ˜์ด ์ด์šฉ๋‚ด์—ญ
@OneToMany(mappedBy = "store", cascade = CascadeType.PERSIST)
@OneToMany(mappedBy = "store", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Paylist> paylists = new ArrayList<>();

// ๋ณด์œ  ์กฐ๊ฐ
@OneToMany(mappedBy = "store", cascade = CascadeType.PERSIST)
@OneToMany(mappedBy = "store", cascade = CascadeType.ALL, orphanRemoval = true)
private List<MyPiece> myPieces = new ArrayList<>();

// ๋ฆฌ๋ทฐ
@OneToMany(mappedBy = "store", cascade = CascadeType.PERSIST)
@OneToMany(mappedBy = "store", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Reviews> reviews = new ArrayList<>();

// ์œ„์‹œ๋ฆฌ์ŠคํŠธ
@OneToMany(mappedBy = "store", cascade = CascadeType.PERSIST)
@OneToMany(mappedBy = "store", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Wishlist> wishlists = new ArrayList<>();

// ๊ฐ€๊ฒŒ ์ด๋ฏธ์ง€
@OneToMany(mappedBy = "store", cascade = CascadeType.PERSIST)
@OneToMany(mappedBy = "store", cascade = CascadeType.ALL, orphanRemoval = true)
private List<StoreImage> storeImages = new ArrayList<>();

// ์นด๋“œ ์ด์šฉ๋‚ด์—ญ
@OneToMany(mappedBy = "store", cascade = CascadeType.PERSIST)
@OneToMany(mappedBy = "store", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Cardlist> cardlists = new ArrayList<>();

// ๊ธฐํƒ€
@Builder
private Store(String name, StoreType type, StoreCategory category, String address, Double latitude,
private Store(String name, StoreType type, StoreCategory category, String address, Double latitude, Area area,
Double longitude, Integer percent) {
this.name = name;
this.type = type;
this.category = category;
this.address = address;
this.latitude = latitude;
this.area = area;
this.longitude = longitude;
this.percent = percent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class StoreImage extends BaseEntity {
private Store store;

@Builder
private StoreImage(String url) {
private StoreImage(String url, Store store) {
this.url = url;
this.store = store;
}
}
}
12 changes: 6 additions & 6 deletions src/main/java/com/groom/swipo/domain/user/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,27 @@ public class User extends BaseEntity {

// ๋ฐ‘์— ์—ฐ๊ด€๊ด€๊ณ„ ์ ์–ด๋‘๊ธฐ
// ํŽ˜์ด ์ถฉ์ „๋‚ด์—ญ
@OneToMany(mappedBy = "user", cascade = CascadeType.PERSIST)
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
private List<PayChargelist> payChargelists = new ArrayList<>();

// ๋ณด์œ ์กฐ๊ฐ
@OneToMany(mappedBy = "user", cascade = CascadeType.PERSIST)
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
private List<MyPiece> myPieces = new ArrayList<>();

// ๋ฆฌ๋ทฐ
@OneToMany(mappedBy = "user", cascade = CascadeType.PERSIST)
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Reviews> reviews = new ArrayList<>();

// ๊ด€์‹ฌ
@OneToMany(mappedBy = "user", cascade = CascadeType.PERSIST)
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Wishlist> wishlists = new ArrayList<>();

// ์นด๋“œ
@OneToMany(mappedBy = "user", cascade = CascadeType.PERSIST)
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Card> Cards = new ArrayList<>();

// ํŽ˜์ด
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "pay_id")
private Pay pay;

Expand Down

0 comments on commit c5708a3

Please sign in to comment.