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 17:50 Go to next message
Tiziano  is currently offline Tiziano
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 09:45 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
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 15:41 Go to previous messageGo to next message
Tiziano  is currently offline Tiziano
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 10:12 Go to previous message
James Sutherland is currently offline James Sutherland
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: Sat Aug 30 08:26:11 EDT 2014

Powered by FUDForum. Page generated in 0.02071 seconds