如何避免使用集合提取指定的警告“firstResult / maxResults;在内存中应用!“? [英] How can I avoid the Warning "firstResult/maxResults specified with collection fetch; applying in memory!"?

查看:810
本文介绍了如何避免使用集合提取指定的警告“firstResult / maxResults;在内存中应用!“?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器日志使用集合提取指定的firstResult / maxResults中发出警告;在内存中应用!。但一切工作正常。但我不想要这样的警告。



我的代码是



  public employee find(int id){
return(employee)getEntityManager()。createQuery(QUERY).setParameter(id,id).getSingleResult();
}



我的查询是



< pre-class =lang-java prettyprint-override> QUERY =from employee as emp left join fetch emp.salary left join fetch emp.department where emp.id =:id


解决方案

此警告的原因是,当使用fetch连接时,仅由所选实体的ID(而不是通过连接提取)来定义。



如果内存中的这种排序导致问题,请勿在JOIN FETCH中使用firsResult / maxResults。

I'm getting a warning in the Server log "firstResult/maxResults specified with collection fetch; applying in memory!". However everything working fine. But I don't want this warning.

My code is

public employee find(int id) {
    return (employee) getEntityManager().createQuery(QUERY).setParameter("id", id).getSingleResult();
}

My query is

QUERY = "from employee as emp left join fetch emp.salary left join fetch emp.department where emp.id = :id"

解决方案

Reason for this warning is that when fetch join is used, order in result sets is defined only by ID of selected entity (and not by join fetched).

If this sorting in memory is causing problems, do not use firsResult/maxResults with JOIN FETCH.

这篇关于如何避免使用集合提取指定的警告“firstResult / maxResults;在内存中应用!“?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆