从子句中的jpa eclipselink子查询 [英] jpa eclipselink subquery in from clause

查看:28
本文介绍了从子句中的jpa eclipselink子查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里读到https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/JPQL#Sub-selects_in_FROM_clause

那个eclipselink在from子句中支持子查询

that eclipselink support subquery in from clause

但是当我使用这个查询时

but when i'm using this query

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 子句中的子查询是否真的有效,如果不知道有没有其他方法可以做到这一点,除非使用原生查询.

does any buddy knows if the subquery in from clause is actually working, and if No is there any other way to do this unless using native query.

PS:我使用的是 eclipselink 2.5.0.v20130507

PS: I m using eclipselink 2.5.0.v20130507

推荐答案

您的错误很简单:您的查询格式错误,在 select distinct 中缺少逗号...您有:

Your error is simple: Your query is malformed, is missing a comma in the select distinct... you have:

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 

第三行和第四行之间少了逗号,应该是:

Between the third and fourth line is missing the comma, it should be:

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

这篇关于从子句中的jpa eclipselink子查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆