Skip to content

Commit

Permalink
feat: entity 생성 #2
Browse files Browse the repository at this point in the history
  • Loading branch information
zzimnii committed Jan 2, 2024
1 parent 070a081 commit f893c66
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/java/com/hackerton/demo/domain/Input.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.hackerton.demo.domain;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import lombok.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

@Entity
@Getter
@DynamicUpdate
@DynamicInsert
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Input {

@Id
private Long id;

private String content;
}
25 changes: 25 additions & 0 deletions src/main/java/com/hackerton/demo/domain/Result.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.hackerton.demo.domain;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import lombok.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;


@Entity
@Getter
@DynamicUpdate
@DynamicInsert
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Result {

@Id
private Long id;

private String content;

private String keyword;
}
22 changes: 22 additions & 0 deletions src/main/java/com/hackerton/demo/domain/common/BaseEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.hackerton.demo.domain.common;

import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
@Getter
public abstract class BaseEntity {

@CreatedDate
private LocalDateTime createdAt;

@LastModifiedDate
private LocalDateTime updatedAt;
}
24 changes: 24 additions & 0 deletions src/main/java/com/hackerton/demo/domain/mapping/Keyword.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.hackerton.demo.domain.mapping;

import com.hackerton.demo.domain.Result;
import com.hackerton.demo.domain.common.BaseEntity;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Getter
@Builder
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@AllArgsConstructor
public class Keyword extends BaseEntity {

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

private String title;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "result_id")
private Result result;
}

0 comments on commit f893c66

Please sign in to comment.