Reply
⬇️ Lembrar de criar Getters and Setters + equals&hashcode com ID.
❗Nunca coloque um Set do relacionamento dentro do construtor.
Atualizado
⬇️ Lembrar de criar Getters and Setters + equals&hashcode com ID.
❗Nunca coloque um Set do relacionamento dentro do construtor.
@Entity
@Table(name = "tb_reply")
public class Reply {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(columnDefinition = "TEXT")
private String body;
@Column(columnDefinition = "TIMESTAMP WITHOUT TIME ZONE")
private Instant moment;
@ManyToOne
@JoinColumn(name = "author_id")
private User author;
@ManyToOne
@JoinColumn(name = "topic_id")
private Topic topic;
@ManyToMany
@JoinTable(name = "tb_reply_likes",
joinColumns = @JoinColumn(name = "reply_id"),
inverseJoinColumns = @JoinColumn(name = "user_id")
)
private Set<User> likes = new HashSet<>();
Atualizado