query.setMaxResults() 导致 toplink 出现问题

发布于 2024-10-06 17:54:07 字数 630 浏览 0 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寄离 2024-10-13 17:54:07

我猜如果没有 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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文