Error on Query - CollectionDatasource

Hi,

I have the following datasource:

<collectionDatasource id="membersByGenderDs"
                              class="com.inoutech.yfams.entity.Member"
                              view="member-browser">
            <query>
                <![CDATA[select e.gender, count(e.id) from yfams$Member e group by e.gender]]>
            </query>
</collectionDatasource>

But when it runs I get:

IllegalArgumentException: Query
select e.gender, count(e.id) from yfams$Member e group by e.gender
, query hint eclipselink.left-join-fetch is not valid for this type of query.

What is wrong with the query?

Thank you

Hi,

The problem is that you cannot use aggregation functions like count, because how should the orm bind the value? It is not tied to a particular entity instance. Also there would be no field to bind it to.

For aggregations you have to use value datasources:
https://doc.cuba-platform.com/manual-6.8/value_datasources.html

Bye
Mario

Hi Mario,

I got it.

Thank you,

Claudio