Try using @Sort
instead:
@OneToMany(fetch = FetchType.LAZY, mappedBy = "videoId", cascade = CascadeType.ALL, orphanRemoval = true)
@Sort(type = SortType.COMPARATOR, comparator = CommentTimeComparator.class)
public List<Comment> getComments()
This way you know it won't affect your SQL. It may also offer a performance improvement by taking pressure off your database - for example, if you have a number of @OneToMany
associations on the same entity that you want sorting.