There are several problems that can come up when size() is used as a select expression.
1) There is no result when a collection is empty.
For example:
---- Original description:
I'm using the following HQL and it return a correct result :
{code:java} select distinct new net.rhuanrocha.dto.CompanyDto(c.id,c.name,0) from Company c left join c.customers cu where c.name =:name group by c.id, c.name
{code}
But when I use the size function in my HQL the query results is wrong (In my case is returning an empty result). Look this HQL:
{code:java} select distinct new net.rhuanrocha.dto.CompanyDto(c.id,c.name,size(c.customers)) from Company c left join c.customers cu where c.name =:name group by c.id, c.name {code} |
|