Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » Problem with Aggregates function and Aritmetics Operation
Problem with Aggregates function and Aritmetics Operation [message #527070] Tue, 13 April 2010 17:50 Go to next message
Eclipse UserFriend
I created a NamedQuery with this sql syntax

SELECT NEW EntityDB.TFattureTotali(t.nIdFattura, SUM(r.nImponibile + r.nQta) ,r.nIvaPercentuale) FROM TFatture t, TFattureR r WHERE t = r.nIdFattura GROUP BY t.nIdFattura,r.nIvaPercentuale HAVING t.nIdFattura = :nIdFattura")

When I execute this query I received this error message:
Exception Description: Syntax error parsing the query [TFattureTotali.TotaleFattura: SELECT NEW EntityDB.TFattureTotali(t.nIdFattura, SUM(r.nImponibile + r.nQta) ,r.nIvaPercentuale) FROM TFatture t, TFattureR r WHERE t = r.nIdFattura GROUP BY t.nIdFattura,r.nIvaPercentuale HAVING t.nIdFattura = :nIdFattura], line 1, column 69: syntax error at [+].
Internal Exception: MismatchedTokenException(89!=82)
It seems that EclipseLink don't accept aritmetics operation in aggregates function
Re: Problem with Aggregates function and Aritmetics Operation [message #527508 is a reply to message #527070] Thu, 15 April 2010 09:45 Go to previous messageGo to next message
Eclipse UserFriend
Please log a bug for this issue.

As a workaround you can use an Expression, Criteria or SQL query.
Re: Problem with Aggregates function and Aritmetics Operation [message #527625 is a reply to message #527508] Thu, 15 April 2010 15:41 Go to previous messageGo to next message
Eclipse UserFriend
First of all thanks for your kindly reply. Sorry for my answer but may you suggest me an example of criteria or expression?
Re: Problem with Aggregates function and Aritmetics Operation [message #528144 is a reply to message #527070] Mon, 19 April 2010 10:12 Go to previous message
Eclipse UserFriend
Expressions would be something like:

ExpressionBuilder t = new ExpressionBuilder(TFatture.class);
ExpressionBuilder r = new ExpressionBuilder(TFattureR.class);
ReportQuery query = new ReportQuery(TFattureR.class, r);
query.addSum("nImponibile", ExpressionMath.add(r.get("nImponibile"), r.get("nQta"));
query.addAttribute("nIvaPercentuale", r.get("nIvaPercentuale"));
query.setSelectionCriteria(t.equal(r.get("nIdFattura")));
query.addGrouping(t.get("nIdFattura"));
query.addGrouping(t.get("nIvaPercentuale"));
query.setHavingExpression(t.get("nIdFattura").equal(r.getParameter( "nIdFattura"));
query.addArgument(nIdFattura);

Criteria would be similar, give it a try, and show what you tried if still having problems.
Previous Topic:Log4j
Next Topic:Problem with ReportQuery
Goto Forum:
  


Current Time: Tue Jul 22 18:52:39 EDT 2025

Powered by FUDForum. Page generated in 0.03908 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top