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
发布于 2015-12-31 02:13:49
您的错误很简单:您的查询格式错误,select distinct中缺少逗号...您必须:
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发布于 2015-12-30 22:03:13
尝试删除子查询后的“AS”字符串。您展示的文章没有使用这种结构。
https://stackoverflow.com/questions/34530464
复制相似问题