In nHibernate, if you do an HQL query with "join fetch" to eagerly load a child collection, nHibernate will ignore SetMaxResults and SetFirstResult and try to retrieve every single item from the database. Why? This behavior is specific to HQL, as ICriteria supports eager loading (with an outer join, though) and LIMIT.
There are more details here http://www.lesnikowski.com/blog/index.php/nhibernate-ignores-setmaxresults-in-sql/.
Further on the topic and regarding other issues with "join fetch" (such as getting a Cartesian product as a result): as pointed out here and here, it is possible to eagerly load child collections with both HQL and ICriteria. However, ICriteria doesn't allow inner joins (resulting in a Cartesian product), and HQL doesn't allow paging the results on the DB side.
and what to do if a have to do the same thing but paged?
SetMaxResults, but that might cause issues with the loading. At that point, I might want to execute two totally separate queries, first to get just the entities, then to load the related associations.
So what is the issue with paging here and what would be the possible solution?