query.setMaxResults() 导致 toplink 出现问题
我正在使用 JPA (toplink) 并尝试限制 JPQL 查询返回的行数,因此我使用了 Query.setMaxResults 方法,但它抛出以下错误:
Exception [TOPLINK-6121] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.QueryException
Exception Description: The query has not been defined correctly, the expression builder is missing. For sub and parallel queries ensure the queries builder is always on the left.
这是查询:
select distinct d.deptName from Departement d join d.employees e where e.empId in (select distinct a.employee.empId from ApprovedEmpls a join a.NewEmps o)
I am using JPA (toplink) and trying to restrict the number of rows returned by a JPQL query, so I've used Query.setMaxResults
method, but It throws the following error:
Exception [TOPLINK-6121] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.QueryException
Exception Description: The query has not been defined correctly, the expression builder is missing. For sub and parallel queries ensure the queries builder is always on the left.
Here's the query:
select distinct d.deptName from Departement d join d.employees e where e.empId in (select distinct a.employee.empId from ApprovedEmpls a join a.NewEmps o)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜如果没有 maxResults,查询也会失败?
似乎是子选择的问题,尝试删除或更改它(为什么它加入 NewEmps 而根本不使用它?)。您还可以使用本机 SQL 查询作为解决方法。
您应该考虑将 TopLink Essentials 升级到 EclipseLink (TopLink 11g)。
I would guess the query will fail the same without the maxResults?
Seems to be an issue with the sub-selects, try removing or changing it (why does it join NewEmps and not use it at all?). You could also use a native SQL query as a workaround.
You should consider upgrading TopLink Essentials to EclipseLink (TopLink 11g).