-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Entity 구성 #2 #17
Merged
The head ref may contain hidden characters: "feature/#2-Entity\uAD6C\uC131"
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6f79022
chore: 데이터 베이스 설정
Ho-Tea c5b9f5c
feat: Base Entity 구성
Ho-Tea 4665ea4
feat: Pin Entity 구성
Ho-Tea bfd1f65
feat: Travel Entity 구성
Ho-Tea 3e6ea6e
feat: Member Entity 구성
Ho-Tea 899754d
feat: Mate Entity 구성
Ho-Tea 3b64557
feat: Visit Entity 구성
Ho-Tea 6a10939
feat: Visit Image Entity 구성
Ho-Tea 30fb168
feat: Visit Log Entity 구성
Ho-Tea 8254200
refactor: Table 애노테이션 삭제
Ho-Tea 9257741
refactor: Soft Delete 적용
Ho-Tea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
backend/src/main/java/com/staccato/config/JpaAuditingConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.staccato.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ||
|
||
@Configuration | ||
@EnableJpaAuditing | ||
public class JpaAuditingConfig { | ||
} |
23 changes: 23 additions & 0 deletions
23
backend/src/main/java/com/staccato/config/domain/BaseEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.staccato.config.domain; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import jakarta.persistence.EntityListeners; | ||
import jakarta.persistence.MappedSuperclass; | ||
|
||
import org.springframework.data.annotation.CreatedDate; | ||
import org.springframework.data.annotation.LastModifiedDate; | ||
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
||
import lombok.Getter; | ||
|
||
@MappedSuperclass | ||
@EntityListeners(AuditingEntityListener.class) | ||
@Getter | ||
public abstract class BaseEntity { | ||
@CreatedDate | ||
private LocalDateTime createdDateTIme; | ||
@LastModifiedDate | ||
private LocalDateTime modifiedDateTime; | ||
private Boolean isDeleted = false; | ||
} |
27 changes: 27 additions & 0 deletions
27
backend/src/main/java/com/staccato/member/domain/Member.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.staccato.member.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
|
||
import org.hibernate.annotations.SQLDelete; | ||
|
||
import com.staccato.config.domain.BaseEntity; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@SQLDelete(sql = "UPDATE member SET is_deleted = true WHERE id = ?") | ||
public class Member extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Column(nullable = false, unique = true) | ||
private String nickname; | ||
@Column(columnDefinition = "TEXT") | ||
private String imageUrl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.staccato.pin.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
|
||
import org.hibernate.annotations.SQLDelete; | ||
|
||
import com.staccato.config.domain.BaseEntity; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@SQLDelete(sql = "UPDATE pin SET is_deleted = true WHERE id = ?") | ||
public class Pin extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Column(nullable = false) | ||
private String place; | ||
@Column(nullable = false) | ||
private String address; | ||
} |
32 changes: 32 additions & 0 deletions
32
backend/src/main/java/com/staccato/travel/domain/Mate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.staccato.travel.domain; | ||
|
||
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 org.hibernate.annotations.SQLDelete; | ||
|
||
import com.staccato.config.domain.BaseEntity; | ||
import com.staccato.member.domain.Member; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@SQLDelete(sql = "UPDATE mate SET is_deleted = true WHERE id = ?") | ||
public class Mate extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id", nullable = false) | ||
private Member member; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "travel_id", nullable = false) | ||
private Travel travel; | ||
} |
35 changes: 35 additions & 0 deletions
35
backend/src/main/java/com/staccato/travel/domain/Travel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.staccato.travel.domain; | ||
|
||
import java.time.LocalDate; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
|
||
import org.hibernate.annotations.SQLDelete; | ||
|
||
import com.staccato.config.domain.BaseEntity; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@SQLDelete(sql = "UPDATE travel SET is_deleted = true WHERE id = ?") | ||
public class Travel extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Column(columnDefinition = "TEXT") | ||
private String thumbnailUrl; | ||
@Column(nullable = false, length = 50) | ||
private String title; | ||
@Column(columnDefinition = "TEXT") | ||
private String description; | ||
@Column(nullable = false) | ||
private LocalDate startAt; | ||
@Column(nullable = false) | ||
private LocalDate endAt; | ||
} |
38 changes: 38 additions & 0 deletions
38
backend/src/main/java/com/staccato/visit/domain/Visit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.staccato.visit.domain; | ||
|
||
import java.time.LocalDate; | ||
|
||
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 org.hibernate.annotations.SQLDelete; | ||
|
||
import com.staccato.config.domain.BaseEntity; | ||
import com.staccato.pin.domain.Pin; | ||
import com.staccato.travel.domain.Travel; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@SQLDelete(sql = "UPDATE visit SET is_deleted = true WHERE id = ?") | ||
public class Visit extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Column(nullable = false) | ||
private LocalDate visitedAt; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "pin_id", nullable = false) | ||
private Pin pin; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "travel_id", nullable = false) | ||
private Travel travel; | ||
} |
31 changes: 31 additions & 0 deletions
31
backend/src/main/java/com/staccato/visit/domain/VisitImage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.staccato.visit.domain; | ||
|
||
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 org.hibernate.annotations.SQLDelete; | ||
|
||
import com.staccato.config.domain.BaseEntity; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@SQLDelete(sql = "UPDATE visit_image SET is_deleted = true WHERE id = ?") | ||
public class VisitImage extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Column(columnDefinition = "TEXT") | ||
private String imageUrl; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "visit_id", nullable = false) | ||
private Visit visit; | ||
} |
35 changes: 35 additions & 0 deletions
35
backend/src/main/java/com/staccato/visit/domain/VisitLog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.staccato.visit.domain; | ||
|
||
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 org.hibernate.annotations.SQLDelete; | ||
|
||
import com.staccato.config.domain.BaseEntity; | ||
import com.staccato.member.domain.Member; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@SQLDelete(sql = "UPDATE visit_log SET is_deleted = true WHERE id = ?") | ||
public class VisitLog extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Column(columnDefinition = "TEXT") | ||
private String content; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "visit_id", nullable = false) | ||
private Visit visit; | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id", nullable = false) | ||
private Member member; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
spring: | ||
application: | ||
name: staccato | ||
sql: | ||
init: | ||
mode: always | ||
h2: | ||
console: | ||
enabled: true | ||
datasource: | ||
url: jdbc:h2:mem:staccato | ||
jpa: | ||
show-sql: true | ||
properties: | ||
hibernate: | ||
format_sql: true | ||
hibernate: | ||
ddl-auto: create | ||
defer-datasource-initialization: true |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안써봐서 잘 모르긴 하는데, 찾아보니까
columnDefinition
은 특정 데이터베이스에 종속적이므로@Lob
을 사용하는 것을 추천하는 것 같은데 어떻게 생각하시나요?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h2에서는
TEXT
자료형이 사용되지 않는다고 알려져있는데 문제 없이 DDL이 생성되는 것을보고 현재는@Lob
을 사용하지 않았습니다!