In a program I have to maintain, there is one point where a single, simple query is executed.
The query looks like this:
<named-query name="retrievePolicySet">
<query>from PSTRepresentationType p where p.realm=? AND p.policySetType.policySetId=?</query>
</named-query>
The type PSTRepresentationType has a many-to-one association, mapping many PolicySetTypes to one PSTRepresentationType.
When the query gets executed, it not only creates one but 45 additional select statements!
Could this be a n + 1 problem?
Yes it is. I believe for your case the left join fetch solution should work: http://www.javalobby.org/articles/hibernate-query-101/.