Skip to content

Commit

Permalink
fix: apply ulid
Browse files Browse the repository at this point in the history
  • Loading branch information
ohksj77 committed Oct 9, 2023
1 parent 3a65168 commit f58e2ab
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'com.github.f4b6a3:ulid-creator:5.2.2'

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'org.postgresql:postgresql'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

import javax.persistence.*;

/**
* 서비스 특성상 초기 SQL 파일로 데이터 저장 후 스프링 코드 상에서 조회만 되는 엔티티입니다.
*/

@Getter
@Entity
@EqualsAndHashCode(of = "englishName")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.doodledoodle.backend.global.audit.AuditListener;
import com.doodledoodle.backend.global.audit.Auditable;
import com.doodledoodle.backend.global.audit.BaseTime;
import com.github.f4b6a3.ulid.UlidCreator;
import lombok.*;
import org.hibernate.annotations.GenericGenerator;

Expand All @@ -18,17 +19,16 @@
public class Draw implements Auditable {

@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
private UUID id;
@Column(name = "id", columnDefinition = "BINARY(16)")
private UUID id = UlidCreator.getMonotonicUlid().toUuid();

private String imageUrl;

@Column(nullable = false)
private Integer playerNo;

@JoinColumn
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(columnDefinition = "BINARY(16)")
private Game game;

@Setter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.doodledoodle.backend.global.audit.AuditListener;
import com.doodledoodle.backend.global.audit.Auditable;
import com.doodledoodle.backend.global.audit.BaseTime;
import com.github.f4b6a3.ulid.UlidCreator;
import lombok.*;
import org.hibernate.annotations.GenericGenerator;

Expand All @@ -17,9 +18,8 @@
public class Game implements Auditable {

@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
private UUID id;
@Column(name = "id", columnDefinition = "BINARY(16)")
private UUID id = UlidCreator.getMonotonicUlid().toUuid();

@JoinColumn
@ManyToOne(fetch = FetchType.LAZY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
@EqualsAndHashCode(of = "draw")
@EntityListeners(AuditListener.class)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(indexes =
{@Index(name = "game_id_index", columnList = "game_id"),
@Index(name = "draw_id_index", columnList = "draw_id")})
public class Result implements Auditable {

@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", columnDefinition = "BINARY(16)")
private UUID id;

@JoinColumn
Expand All @@ -34,12 +32,12 @@ public class Result implements Auditable {
@Column(nullable = false)
private Double similarity;

@JoinColumn
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(columnDefinition = "BINARY(16)")
private Game game;

@JoinColumn
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(columnDefinition = "BINARY(16)")
private Draw draw;

@Column(nullable = false)
Expand Down

0 comments on commit f58e2ab

Please sign in to comment.