-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b0c764
commit fb8557d
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/main/kotlin/org/meogo/domain/comment/domain/Comment.kt
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,37 @@ | ||
package org.meogo.domain.comment.domain | ||
|
||
import org.meogo.domain.post.domain.Post | ||
import org.meogo.domain.user.domain.User | ||
import java.time.LocalDateTime | ||
import javax.persistence.CascadeType.REMOVE | ||
import javax.persistence.Column | ||
import javax.persistence.Entity | ||
import javax.persistence.FetchType | ||
import javax.persistence.GeneratedValue | ||
import javax.persistence.GenerationType | ||
import javax.persistence.Id | ||
import javax.persistence.JoinColumn | ||
import javax.persistence.ManyToOne | ||
|
||
@Entity | ||
class Comment( | ||
|
||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Id | ||
val id: Long = 0, | ||
|
||
@Column(nullable = false) | ||
var content: String, | ||
|
||
@Column(nullable = false) | ||
val date: LocalDateTime, | ||
|
||
@ManyToOne(cascade = [REMOVE], fetch = FetchType.LAZY) | ||
@JoinColumn(name = "post_id", nullable = false) | ||
val post: Post, | ||
|
||
@ManyToOne(cascade = [REMOVE], fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_id", nullable = false) | ||
val user: User | ||
|
||
) |
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/org/meogo/domain/comment/domain/CommentRepository.kt
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,5 @@ | ||
package org.meogo.domain.comment.domain | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository | ||
|
||
interface CommentRepository : JpaRepository<Comment, Long> |