Actually my comment is nonsense: the JPA spec doesn’t support subqueries in the select clause, but Hibernate 5 definitely does. So you can write your query like this: select b, (select max(c.number) from b.chapters c) as chnum from Book b order by chnum Or you can write it using the approach I suggested above: select b, max(c.number) as chnum from Book b join b.chapters c group by b order by chnum |