Enhancement 419 : Simplify aggregation queries
Priority 
Medium
Reported Version 
 
Logged By 
bthule
Status 
Fixed
Fixed Version 
github
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
21/08/2012
Updated 
21/08/2012
Type 
Enhancement
 
Attachments 
No attachments

I wanted to do the simple queries:
"select userid, count(*) from roles group by userid"
"select count(*) from entries where userid=:userid"

And I found it was difficult to do through Ebean. RawSql might work, but it's not easy or elegant, and even with that, I don' think there is a way to return the result to a scalar or other non entity classes.

In these cases of doing flat non-oo type report queries, it should be possible to return the result as a List or List>.


Long customerCount = Ebean.find(Customer.class).select("count(*)").findScalar(Long.class);

List> customersCount = Ebean.find(Customer.class).select("customerId, count(*)".where().like("name", name).groupBy("customerid").findList.class>);

List customersCount = Ebean.find(Customer.class).select("customerId, count(*)".groupBy("customerid").findList);

 
woResponse

Upload a file