小编典典

避免使用集合获取指定“ HHH000104:firstResult / maxResults”;申请内存!” 使用Spring Data [重复]

hibernate

我在服务器日志 “用集合获取指定的firstResult / maxResults;在内存中应用!”中 收到警告
。但是,一切正常。但我不要这个警告。

我的代码是

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

我的查询是

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

阅读 552

收藏
2020-06-20

共1个答案

小编典典

该警告的原因是,当使用访存联接时,结果集中的顺序仅由所选实体的ID定义(而不是由访存的联接定义)。

如果内存中的这种排序引起问题,请不要在JOIN FETCH中使用firsResult / maxResults。

2020-06-20