I am 100% sure I did not fully explain my question in the title. My English wasn't enough to explain.
I have 2 Entities. User
and Book
. User has a list named readBooks
. I want to reach the books in that list using HQL.
@Entity
public class Book {
... (nothing about users)
}
@Entity
public class User extends BaseUser {
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.DETACH})
private List<Book> readList;
@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.DETACH})
private List<Book> favoriteList;
}
I know I can easily reach the readList
with user.getReadList()
. However, I need to reach that list using HQL so that I can apply server-side pagination and sorting easily by just adding a Pagable
to the function.