Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 21:50 Go to next message
Tiziano  is currently offline Tiziano Friend
Messages: 6
Registered: April 2010
Junior Member
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 13:45 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Please log a bug for this issue.

As a workaround you can use an Expression, Criteria or SQL query.


James : Wiki : Book : Blog : Twitter
Re: Problem with Aggregates function and Aritmetics Operation [message #527625 is a reply to message #527508] Thu, 15 April 2010 19:41 Go to previous messageGo to next message
Tiziano  is currently offline Tiziano Friend
Messages: 6
Registered: April 2010
Junior Member
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 14:12 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

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.


James : Wiki : Book : Blog : Twitter
Previous Topic:Log4j
Next Topic:Problem with ReportQuery
Goto Forum:
  


Current Time: Thu Apr 18 08:33:41 GMT 2024

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

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

Back to the top