Witajcie,
Mam problem ze spring data, a dokładniej z zastosowaniem obiektu Page przy pobieraniu wyników zapytania. Poniższa metoda działa poprawnie:

List<Post> findLatestPostForEveryTopicInCategory(@Param("name") String category, Pageable pageable);

Natomiast użycie obiektu Page w sposób taki jak poniżej powoduje wyrzucenie wyjątku:

Page<Post> findLatestPostForEveryTopicInCategory(@Param("name") String category, Pageable pageable);

Wyjątek

org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list [FromElement{explicit,not a collection join,fetch join,fetch non-lazy properties,classAlias=t,role=pl.zaprogramowany.cms.entity.Post.topic,tableName=topics,tableAlias=topic1_,origin=posts post0_,columns={post0_.topic_id ,className=pl.zaprogramowany.cms.entity.Topic}}]

Zapytanie:

SELECT DISTINCT p FROM Post p JOIN FETCH p.creator user JOIN FETCH p.topic t JOIN FETCH t.category c WHERE c.name = :name AND (p.date = (SELECT MAX(po.date) FROM Post po JOIN po.topic to WHERE to = t) OR p.date = (SELECT MIN(po.date) FROM Post po JOIN po.topic to WHERE to = t)) ORDER BY p.date DESC"