AllanJack
AllanJack

Reputation: 55

Hibernate CreateQuery sum() always returning Long type

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!

Upvotes: 0

Views: 1342

Answers (1)

Shahab Bagheri
Shahab Bagheri

Reputation: 89

try this :

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

Upvotes: 1

Related Questions