From 9436d4927dc5035c83620bdd1dd34600370dce56 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 1 Jul 2024 04:10:37 +0300 Subject: JPA: fix relations, add new fields, add basic tests --- src/main/java/com/juick/data/entities/ReplyEntity.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/juick/data/entities/ReplyEntity.java') diff --git a/src/main/java/com/juick/data/entities/ReplyEntity.java b/src/main/java/com/juick/data/entities/ReplyEntity.java index e7f3d053..bc0795cf 100644 --- a/src/main/java/com/juick/data/entities/ReplyEntity.java +++ b/src/main/java/com/juick/data/entities/ReplyEntity.java @@ -24,11 +24,12 @@ import jakarta.persistence.*; public class ReplyEntity extends BaseMessagePropertyEntity { @Id @Column(name = "reply_id") - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long replyId; @Column(name = "txt") - private - String text; + private String text; + @ManyToOne(cascade = CascadeType.MERGE) + private UserEntity user; public String getText() { return text; @@ -45,4 +46,12 @@ public class ReplyEntity extends BaseMessagePropertyEntity { public void setReplyId(Long replyId) { this.replyId = replyId; } + + public UserEntity getUser() { + return user; + } + + public void setUser(UserEntity user) { + this.user = user; + } } -- cgit v1.2.3