Hibernate CreateQuery sum() always returning Long type

1.1k Views Asked by At

I did a query to get the sum of values in a table: List<Double> resultList = (List<Double>) em.createQuery("SELECT sum(v.prices) FROM Ship v).getResultList();

The problem is that even though i typed as Double, the return continues to be Long and the decimals are not included.

Can someone help me with this issue? Pls

Thanks!

1

There are 1 best solutions below

1
Shahab Bagheri On

try this :

List<Double> resultList = (List<Double>) em.createQuery("SELECT sum(cast(v.prices as double)) FROM Ship v).getResultList();