Pie Chart data

I’m trying to create a pie chart for my application-browse screen. I need to display a chart that shows the number of applications in each status. I’m using a view that includes status as it’s an entity. I can’t seem to get the query to work if I include a count(e) keyword. Here is my query:
select e.status
from edge$Application e
group by e.status
order by e.status

This is the error I receive within cuba:
IllegalArgumentException: Query select tempEntityAlias from edge$Status tempEntityAlias, edge$Application e where tempEntityAlias.id = e.status.id group by e.status order by e.status, query hint eclipselink.batch is not valid for this type of query.

1 Like

Currently neither CollectionDatasource, nor DataManager query can return aggregates or single attributes - they can only return entities. This is because of security considerations - there can be restrictions on entity attributes and the platform generic mechanisms now can check them only inside entities.

So when you need to load aggregates or any other scalar values to the client, create your own service and use EntityManager with JPQL or native queries. To display such data in a chart, use DataProvider as explained in this example: https://doc.cuba-platform.com/charts-6.2/chart_with_data_provider.html

We have plans for implementing a simple display of arbitrary data in tables and charts in a future release. It will be possible when we are able to fully analyze JPQL queries for attribute restrictions.