我正在尝试执行下面的Named查询,但它无法通过JPQLParser进行解析。查询得到解析如果我尝试删除包含JOIN FETCH的以下两个粗线。 我使用的是8发货JPA 2.X
作为JOIN FETCH的业务对象“applicationItem”和“application”在业务类“AdmissionItem”和“ApplicationItem”中标记为LAZY FETCH
以下查询在JPA 1.X中运行绝对正常但在JPA 2.X
中失败"SELECT DISTINCT request FROM Request request
WHERE request.genId IN
(
SELECT DISTINCT applicationItem.request.genId
FROM ApplicationItem applicationItem
WHERE applicationItem.genId IN
(
SELECT DISTINCT admissionItem.applicationItem.genId
FROM AdmissionItem admissionItem
**JOIN FETCH admissionItem.applicationItem
JOIN FETCH admissionItem.applicationItem.application**
WHERE admissionItem.genId IN
(
// more query
)
AND admissionItem.applicationItem.application.name='SMA'
)
)"
org.apache.openjpa.persistence.ArgumentException:“遇到”请求。 genId IN(SELECT DISTINCT applicationItem.request.genId FROM ApplicationItem applicationItem WHERE applicationItem.genId IN(SELECT DISTINCT admissionItem.applicationItem.genId FROM AdmissionItem admissionItem JOIN FETCH“at character 31,but expected:[”(“,”)“,”* “,”+“,”,“,” - “,”。“,”/“,”:“,”<“,”< =“,”<>“,”=“,”> ;“,”> =“,”?“,”ABS“,”ALL“,”AND“,”ANY“,”AS“,”ASC“,”AVG“,”BETWEEN“,”BOTH“,” BY“,”CONCAT“,”COUNT“,”CURRENT_DATE“,”CURRENT_TIME“,”CURRENT_TIMESTAMP“,”DELETE“,”DESC“,”DISTINCT“,”EMPTY“,”ESCAPE“,”EXISTS“,”FETCH“ ,“FROM”,“GROUP”,“HAVING”,“IN”,“INNER”,“IS”,“JOIN”,“LEADING”,“LEFT”,“LENGTH”,“LIKE”,“LOCATE”,“ LOWER“,”MAX“,”MEMBER“,”MIN“,”MOD“,”NEW“,”NOT“,”NULL“,”OBJECT“,”OF“,”OR“,”ORDER“,”OUTER“ ,“SELECT”,“SET”,“SIZE”,“SOME”,“SQRT”,“SUBSTRING”,“SUM”,“TRAILING”,“TRIM”,“TYPE”,“UPDATE”,“UPPER”,“ WHERE“,,,,,,,,,]。”解析JPQL时
at org.apache.openjpa.kernel.jpql.JPQLParser.parse(JPQLParser.java:51)