Код: Выделить всё
@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Comments {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private Long quotationId;
@ManyToOne
@JoinColumn(name = "uid", referencedColumnName = "uid", nullable = false)
private UserProfile user;
@Size(min = 5, max = 300)
private String comment;
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "comment_likes", joinColumns = @JoinColumn(name = "comment_id"), inverseJoinColumns = @JoinColumn(name = "user_id"))
private Set likedBy = new HashSet();
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "comment_unreads", joinColumns = @JoinColumn(name = "comment_id"), inverseJoinColumns = @JoinColumn(name = "user_profile_id"))
private Set readBy = new HashSet();
@CreationTimestamp
private LocalDateTime createdAt;
// Update read status
public void markAsReadBy(UserProfile user) {
this.readBy.remove(user);
}
// Method to populate users who have commented on the same quotation
public void populateReadBy(Set allUsersForQuotation, Long uid) {
allUsersForQuotation.forEach(user -> {
// Exclude the user who created the comment
if (user.getUser().getUid().equals(uid)) {
this.readBy.remove(user);
}
else {
this.readBy.add(user);
}
});
}
}
Мой вопрос: таблица comment_unreads содержит столбцы comment_id и user_profile_id, но как я могу добавить к ней столбец email_sent?
Подробнее здесь: https://stackoverflow.com/questions/793 ... -jointable
Мобильная версия