...
> I don't see this a big problem. Essentially, count() is the only 
> aggregation function that makes sense without projection. So I think
> it is acceptable to have something like
> project("id").aggregate("count").

I don't see it as a problem per say, I just thought it was redundant,
but if it is necessary for uniformity it wouldn't bother me much.

> > If in Michael's example you could do something like the following,
> > without it affecting the results of .list(), then I think it would
> > meet my present needs (assuming it applied to count as well):
> > 
> > Criteria criteria = session.createCriteria(Some.class)
> >     .add(Expression.eq("any", value);
> > Double sum = criteria.project("property")
> >     .aggregate(Aggregate.SUM);
> > List objects = criteria.list();
> 
> Actually that is not such a bad idea ... imho aggregating does not
> need to be chainable. max(sum(xxx)) does not make sense without
> grouping, which is not available in the Criteria API (should it ever
> be?).
> 
> If it works to make aggregate execute the query without leaving any 
> traces in the criteria we could do
> 
> Integer count = criteria.project(xxx).aggregate(Aggregate.COUNT);
> 
> This would still not solve the "want to reuse my criteria" issue. I 
> don't have a good idea yet on how this could be done cleanly.
> Probably a clearProjection() method or something so one could do
> 
> Integer count = criteria.project("xxx").aggregate(Aggregate.COUNT);
> criteria.clearProjection();
> criteria.list();

I'm not clear on this, would calling .project("xxx").aggregate(...)
modify the criteria such that it could no longer be used to call the
.list() method (or at least not to get the same results anymore)?  
What would .project("xxx") return?  Still a Criteria?  If so, could it
be a new instance thereby making it possible to preserve the one that
made that call if so desired?

Would it make sense to have criteria.add(Projection) or
criteria.add(Aggregation) the way there is criteria.addOrder(Order) and
criteria.add(Criterion)?  (Out of curiosity, why is it addOrder(Order)
as opposed to just add(Order)?)


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
hibernate-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to