Minu Jain wrote:
How can option e and b be correct???
Isn't SUM supposed to return Long when applied to state-fields of integral types???
Also, in line 22, how can getSingleResult() return an array of Object??? So option e also should be incorrect.
Please help............
Thanks in advance!
SUM aggregate function can return the following types: Long, Double, BigInteger and BigDecimal depending on the
field type.
Which means, Theoretically (i've never tried) that since you can Narrow a Long into an Integer, the result could be
an int as well. How this works under the hood, i have no idea, but since the field "children" is marked as "int" i would
expect to get an "int" as a result of the SUM aggregate function...
For the second question, is interesting, ...
I will try that, but maybe is a way to avoid being thrown the javax.persistence.NonUniqueResultException when
the result is not unique... even though there will be only one Row returned from the query, there are actually two
columns in a real database query...one with the SUM and one with the result of the AVG...which are not Koala
entities and i'm not sure how they are seen from the entity manager...
Dave