简体   繁体   中英

query.setMaxResults() causes problems on toplink

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)

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM