Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
from子句中的jpa eclipselink子查询_Jpa_Subquery_Eclipselink - Fatal编程技术网

from子句中的jpa eclipselink子查询

from子句中的jpa eclipselink子查询,jpa,subquery,eclipselink,Jpa,Subquery,Eclipselink,我在这里读 eclipselink在from子句中支持子查询 但是当我使用这个查询时 queryString2="SELECT NEW dz.com.naftal.erp.domain.view.MouvementProduitView('VAR',t.cds,SUM(t.mntttc)) " + "FROM (SELECT DISTINCT m.mouvementProduitViewPK.cds as cds,m.mouvementProduitViewPK.re

我在这里读

eclipselink在from子句中支持子查询

但是当我使用这个查询时

queryString2="SELECT NEW dz.com.naftal.erp.domain.view.MouvementProduitView('VAR',t.cds,SUM(t.mntttc)) " +
             "FROM (SELECT DISTINCT m.mouvementProduitViewPK.cds as cds,m.mouvementProduitViewPK.referenceDocument,m.mouvementProduitViewPK.typeDocument " +
             "m.mntttc as mntttc FROM MouvementProduitView m WHERE m.mouvementProduitViewPK.cds IN :cdss " +
             "AND m.mouvementProduitViewPK.typeDocument IN :typeDocuments " +
             "AND m.dateOperation BETWEEN :dateDu AND :dateAu GROUP BY m.mouvementProduitViewPK.cds ORDER BY m.mouvementProduitViewPK.cds) AS t GROUP BY t.cds"
我犯了这个错误

SEVERE [global]
Local Exception Stack: 
Exception [EclipseLink-0] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing [SELECT NEW.............. 
[388, 388] The right parenthesis is missing from the sub-expression.
[389, 389] An identification variable must be provided for a range variable declaration.
[426, 447] The query contains a malformed ending.
是否有伙伴知道from子句中的子查询是否实际工作,如果没有,是否有其他方法来完成此操作,除非使用本机查询


PS:我正在使用eclipselink 2.5.0.v20130507

尝试删除子查询后的“AS”字符串。您介绍的文章没有使用这种结构。

您的错误很简单:您的查询格式不正确,在“选择不同项”中缺少逗号。。。你有:

SELECT DISTINCT 
    m.mouvementProduitViewPK.cds as cds,
    m.mouvementProduitViewPK.referenceDocument,
    m.mouvementProduitViewPK.typeDocument //Here is missing the comma
    m.mntttc as mntttc 
FROM MouvementProduitView m 
第三行和第四行之间缺少逗号,应为:

SELECT DISTINCT 
    m.mouvementProduitViewPK.cds as cds,
    m.mouvementProduitViewPK.referenceDocument,
    m.mouvementProduitViewPK.typeDocument, //put at the end of this line the comma
    m.mntttc as mntttc 
FROM MouvementProduitView m

显示“选择新…”的错误和没有该文本的查询?因此,您没有显示相同的查询粘贴错误的查询,请检查已编辑的查询。该消息与子查询无关,与“选择新建”有关。那么你是如何调用它的呢?FROM中也没有候选实体,EclipseLink页面示例中确实有一个候选实体。我在MouvementProdutView中有一个带3个参数的构造函数,因此如果我使用select new,则选择new work。。。。从MouvementProduitView m it works,我还尝试将实体条件与select子查询一起使用,得到了相同的结果error@NeilStockton,它是候选实体,我第一次尝试它时它不起作用,因为我有一个语法错误(子查询中的GROUP BY子句),所以你有正确的答案My bad^^',我粘贴了错误的查询,检查编辑的帖子。这不是问题,但它仍然有语法错误,我忘记从子查询中删除GROUPBY子句