How to detect HHH000104 issues with hibernate.query.fail_on_pagination_over_collection_fetch

Introduction Recently, I noticed the hibernate.query.fail_on_pagination_over_collection_fetch configuration property that was introduced in Hibernate 5.2, and I had absolutely no idea it can be used to prevent the HHH000104 Hibernate issues. As previously explained, if you want to overcome the “HHH000104: firstResult/maxResults specified with collection fetch; applying in memory!” issue, you have to either use 2 queries or a window function to fetch and limit the number of parent records while making sure you always fetch all their associated child entities. Even if the HHH000104 issue is logged as a warning message, it… Read More

The best way to fix the Hibernate “HHH000104: firstResult/maxResults specified with collection fetch; applying in memory!” warning message

Introduction If you’ve been using Hibernate long enough, then you surely must have seen this WARN log message when doing pagination while join-fetching multiple entities. HHH000104: firstResult/maxResults specified with collection fetch; applying in memory! In this article, I’m going to show two ways you can to fix this issue.