This is going to be fixed in 6.0. Unfortunately there is nothing you can do for now except for patching it for your own needs which shouldn't be too complicated for postgresql. Essentially what you would have to do is to remove the cut off after the order by clause here: https://github.com/hibernate/hibernate-orm/blob/0a2a5c622e3eb30724e80bc8661c0ac55ebfb2be/hibernate-core/src/main/java/org/hibernate/engine/spi/SubselectFetch.java#L115 Anyway, I would rather go with the strategy you already have implemented and do a join fetch in the second query instead. If you use that for pagination, you might also want to take a look at Blaze-Persistence which handles stuff like that for you efficiently behind the scenes: https://blazebit.com/blog/2016/pagination-blog-post.html |