Skip to content

Commit

Permalink
refactor: 엔티티 not null, unique 설정
Browse files Browse the repository at this point in the history
Co-authored-by: 3juhwan <[email protected]>
Co-authored-by: Arachneee <[email protected]>
Co-authored-by: kunsanglee <[email protected]>
  • Loading branch information
4 people committed Sep 5, 2024
1 parent e872df8 commit e146a8c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
Expand All @@ -25,6 +28,7 @@

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"event_id", "sequence"})})
@Entity
public class BillAction implements Comparable<BillAction> {

Expand All @@ -38,16 +42,18 @@ public class BillAction implements Comparable<BillAction> {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@JoinColumn(name = "event_id", nullable = false)
@ManyToOne(fetch = FetchType.LAZY)
private Event event;

@AttributeOverride(name = "value", column = @Column(name = "sequence"))
@AttributeOverride(name = "value", column = @Column(name = "sequence", nullable = false))
@Embedded
private Sequence sequence;

@Column(length = MAX_TITLE_LENGTH)
@Column(nullable = false, length = MAX_TITLE_LENGTH)
private String title;

@Column(nullable = false)
private Long price;

@OneToMany(mappedBy = "billAction", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package server.haengdong.domain.action;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import lombok.AccessLevel;
import lombok.Getter;
Expand All @@ -19,13 +21,17 @@ public class BillActionDetail {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@JoinColumn(nullable = false)
@ManyToOne(fetch = FetchType.LAZY)
private BillAction billAction;

@Column(nullable = false)
private String memberName;

@Column(nullable = false)
private Long price;

@Column(nullable = false)
private boolean isFixed;

public BillActionDetail(BillAction billAction, String memberName, Long price, boolean isFixed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -20,25 +23,29 @@

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"event_id", "sequence"})})
@Entity
public class MemberAction implements Comparable<MemberAction> {

public static final int MIN_NAME_LENGTH = 1;
public static final int MAX_NAME_LENGTH = 4;
public static final int MAX_NAME_LENGTH = 8;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@JoinColumn(name = "event_id", nullable = false)
@ManyToOne(fetch = FetchType.LAZY)
private Event event;

@AttributeOverride(name = "value", column = @Column(name = "sequence"))
@AttributeOverride(name = "value", column = @Column(name = "sequence", nullable = false))
@Embedded
private Sequence sequence;

@Column(nullable = false, length = MAX_NAME_LENGTH)
private String memberName;

@Column(nullable = false)
@Enumerated(EnumType.STRING)
private MemberActionStatus status;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ public class Event {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false, length = MAX_NAME_LENGTH)
private String name;

@Embedded
@AttributeOverride(name = "value", column = @Column(name = "password"))
@AttributeOverride(name = "value", column = @Column(name = "password", nullable = false))
private Password password;

@Column(nullable = false, unique = true)
private String token;

public Event(String name, String password, String token) {
Expand Down
28 changes: 0 additions & 28 deletions server/src/main/java/server/haengdong/domain/event/EventStep.java

This file was deleted.

0 comments on commit e146a8c

Please sign in to comment.