cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Wells <>
Subject EJBQL with aggregrate function render to Java List
Date Tue, 12 Jan 2010 01:42:31 GMT
Hi All,

I have an EJBQL query selecting a grouped value from a master table
( and the count of detail rows for each grouping (ie count of
the Category.questions), so I get results:
cat1, 5
cat2, 3
cat3, 10

Ideally what I need to do is get the results into a java List<?>, so I was
hoping (by waving magic Cayenne wand!) that this would work:

"select new CategorySummary(, count(q)) from Category c left join
c.questions q group by" returning a List<CategorySummary>...but I
can't get it working.  Is there a prescribed approach for this?

At the moment I get this:

	at org.apache.cayenne.ejbql.parser.Compiler.compileEntityResult(
	at org.apache.cayenne.ejbql.parser.Compiler.compile(
	at org.apache.cayenne.ejbql.parser.EJBQL$EJBQLDefaultParser.compile(
	at org.apache.cayenne.query.EJBQLQuery.getExpression(
	at org.apache.cayenne.query.EJBQLQueryMetadata.resolve(
	at org.apache.cayenne.query.EJBQLQuery.getMetaData(
	at org.apache.cayenne.util.ObjectContextQueryAction.<init>(
	at org.apache.cayenne.access.DataContextQueryAction.<init>(
	at org.apache.cayenne.access.DataContext.onQuery(
	at org.apache.cayenne.access.DataContext.performQuery(

CategorySummary {
    private String name;
    private Number count;

plus getters and setters

The EJB spec says you can do something like:

SELECT NEW com.acme.example.CustomerDetails(, c.status, o.count)
FROM Customer c JOIN c.orders o
WHERE o.count > 100

Does Cayenne support this?

Thanks for any help,


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message