Dafür habe ich Kommentare mit untergeordneten Kommentaren erstellt.
Aber jedes Mal, wenn ich einen Kommentar löschen möchte, eskaliert Hibernate und versucht, einfach alles zu laden.
Das ist meine Kommentar-Entität:
Code: Select all
@Entity
@Setter
@Getter
public class Comment extends AuditedEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
//--Hierarchy for CommentToTicket--
@ManyToOne
private Ticket ticket;
//--Hierarchy for Comments--
@OneToMany(mappedBy = "parentComment", cascade = CascadeType.ALL, orphanRemoval = true)
@OrderBy("createdDate ASC")
private List comments = new ArrayList();
@ManyToOne
private Comment parentComment;
private String commentText; //TODO: pictures? (blob maybe)
private int likes;
private int dislikes;
}
Code: Select all
@Transactional
public void deleteComment(Long id) {
commentRepository.deleteById(id);
}
Wie kann ich das beheben?
Wichtig
Für mein Projekt darf ich kein Lazyload durchführen. Ich weiß, dass dies dieses Problem beheben würde. Gibt es eine andere Lösung?
Mobile version