I have 4 entitles, 1 of them, books, has a relationship between the remaining 3 entities. my FK are ids, when I query the data trough the repository and sort it using Pageable, it somewhat works, it works if I sort it by the attributes in the books table, but when I try to sort it by one of the attributes in the relationship table, it doesn't work. I think it's because it's sorting by the ids and not by the values.
@Repository
public interface BookRepository extends JpaRepository<Book, Long>, JpaSpecificationExecutor<Book> {
@Query("SELECT b FROM Book b JOIN FETCH b.language JOIN FETCH b.genre JOIN FETCH b.author")
Page<Book> findAllBookDetails(Pageable pageable);
}