Hello & sorry for the late reply.
> André Luiz N Sousa wrote:
> Could you send us some useful examples using aggregate functions?
Well, it turns out I was wrong about aggregate functions (I've never tried
to use them until now). Some of their expression names are already there,
but the corresponding way of running functions in queries is not yet
implemented. :(
So for now the only way is to unfortunately resort to SqlSelectQuery:
SqlSelectQuery query = new SqlSelectQuery(Painting.class,
"select sum(estimated_price) from Painting");
List result = context.performQuery(query);
The Painting.class argument seems redundant, but really is not since we
need to know which DataNode (i.e. database) the statement is supposed to
go to.
The above statement results in:
...
[08-24 16:30:23 main] INFO QueryLogger: select sum(estimated_price) from
Painting
[08-24 16:30:23 main] INFO QueryLogger: === returned 1 row. - took 78 ms.
[08-24 16:30:23 main] INFO SimpleTest: result: [{sum=3.00}]
...
Same for avg/min/max/count etc; the result key name should be the name of
the function.
If you need to implement this, please wrap it into a generic function!
Directly messing with SQL completely violates the idea of an O/R mapping.
Holger
-- A: Maybe because some people are too annoyed by top-posting. Q: Why do I not get an answer to my question(s)? A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
This archive was generated by hypermail 2.0.0 : Sun Aug 24 2003 - 10:58:12 EDT