Skip to content

Commit

Permalink
feat: repository 생성 #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoon-Jemin committed Jan 2, 2024
1 parent f893c66 commit 4b23b23
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.hackerton.demo.domain;
package com.hackerton.demo.domain.Input;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import lombok.*;
import org.hibernate.annotations.DynamicInsert;
Expand All @@ -15,7 +17,8 @@
@AllArgsConstructor
public class Input {

@Id
@Id @GeneratedValue
@Column(name = "input_id")
private Long id;

private String content;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.hackerton.demo.domain.Input;

import com.hackerton.demo.domain.Input.Input;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface InputRepository extends JpaRepository<Input, Long> {
}
25 changes: 0 additions & 25 deletions src/main/java/com/hackerton/demo/domain/Result.java

This file was deleted.

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

import com.hackerton.demo.domain.mapping.Keyword;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import java.util.ArrayList;
import java.util.List;


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

@Id @GeneratedValue
@Column(name = "result_id")
private Long id;

private String content;

@OneToMany(mappedBy = "keyword", cascade = CascadeType.ALL) // keyword 양방향 매핑
private List<Keyword> keywords = new ArrayList<>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.hackerton.demo.domain.Result;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface ResultRepository extends JpaRepository<Result, Long> {
}
3 changes: 2 additions & 1 deletion src/main/java/com/hackerton/demo/domain/mapping/Keyword.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.hackerton.demo.domain.mapping;

import com.hackerton.demo.domain.Result;
import com.hackerton.demo.domain.Result.Result;
import com.hackerton.demo.domain.common.BaseEntity;
import jakarta.persistence.*;
import lombok.*;
Expand All @@ -14,6 +14,7 @@ public class Keyword extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "keyword_id")
private Long id;

private String title;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.hackerton.demo.domain.mapping;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface KeywordRespository extends JpaRepository<Keyword, Long> {
}

0 comments on commit 4b23b23

Please sign in to comment.