开发者

Could this be the n + 1 problem?

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 exe开发者_开发知识库cuted, 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/.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜