Hi experts,
How do I use coalesce?
This is my HQL query:
Code:
select distinct pay.id as paymentId
,(pay.amount - coalesce((select sum(payDebt.amount) from PaymentDebt payDebt),0)) as amountR
from Payment pay
But when running the code this gives an java.lang.ArrayIndexOutOfBoundsException: -1
I also tried to use nvl.
Code:
select distinct pay.id as paymentId
,(pay.amount - nvl((select sum(payDebt.amount) from PaymentDebt payDebt),0)) as amountR
from Payment pay
But hibernate seems to translate this to:
Code:
select distinct payment0_.PAYMENT_ID as col_0_0_, payment0_.AMOUNT-nvl() as col_3_0_
from PAYMENT payment0_
Which results in an ORA-00909 error because the number of arguments of nvl is not correct.
We are using Hibernate 3.2.4.
Lennert