diff --git a/src/main/java/com/chat/yourway/model/Contact.java b/src/main/java/com/chat/yourway/model/Contact.java index 70e0dcb..74ad121 100644 --- a/src/main/java/com/chat/yourway/model/Contact.java +++ b/src/main/java/com/chat/yourway/model/Contact.java @@ -54,7 +54,7 @@ public class Contact implements UserDetails { @OneToMany(mappedBy = "sender", fetch = FetchType.LAZY) private List messages; - @ManyToMany(fetch = FetchType.LAZY) + @ManyToMany @JoinTable( schema = "chat", name = "unread_messages", diff --git a/src/main/java/com/chat/yourway/model/Message.java b/src/main/java/com/chat/yourway/model/Message.java index 646c677..f8f2696 100644 --- a/src/main/java/com/chat/yourway/model/Message.java +++ b/src/main/java/com/chat/yourway/model/Message.java @@ -24,7 +24,7 @@ public class Message { @Column(nullable = false) private LocalDateTime timestamp; - @ManyToOne(fetch = FetchType.EAGER) + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "topic_id", referencedColumnName = "id", nullable = false) private Topic topic; diff --git a/src/main/java/com/chat/yourway/model/Topic.java b/src/main/java/com/chat/yourway/model/Topic.java index 8e7b2f0..c27da1a 100644 --- a/src/main/java/com/chat/yourway/model/Topic.java +++ b/src/main/java/com/chat/yourway/model/Topic.java @@ -38,7 +38,7 @@ public class Topic { @CreationTimestamp private LocalDateTime createdAt; - @ManyToMany(fetch = FetchType.LAZY) + @ManyToMany @JoinTable( schema = "chat", name = "topic_tags", @@ -46,7 +46,7 @@ public class Topic { inverseJoinColumns = @JoinColumn(name = "tag_id")) private Set tags; - @ManyToMany(fetch = FetchType.LAZY) + @ManyToMany @JoinTable( schema = "chat", name = "topic_contacts", @@ -54,7 +54,7 @@ public class Topic { inverseJoinColumns = @JoinColumn(name = "contact_id")) private List topicSubscribers = new ArrayList<>(); - @ManyToMany(fetch = FetchType.LAZY) + @ManyToMany @JoinTable( schema = "chat", name = "topic_complaints",