I am trying to upgrade an existing app from Spring Boot 2.7/Hibernate 5.4 to Spring Boot 3.1.2/Hibernate 6.2.6. Both setups use H2 2.1.214.
Tests that used to work in the original setup are failing. I’ve debugged this to a point that I know it is because of the way a JPQL query is getting translated in SQL. In the working version, the query gets translated as below.
update account_balances set balance_magnitude=balance_magnitude+?,
unreconciled_debit_amount_magnitude=unreconciled_debit_amount_magnitude+?,
unreconciled_credit_amount_magnitude=unreconciled_credit_amount_magnitude+?
where account_id=?
Whereas, with the new combination, the query gets translated as below.
update account_balances set
balance_magnitude=(balance_magnitude+cast(? as
numeric($p,$s))),unreconciled_debit_amount_magnitude=(unreconciled_debit_amount_magnitude+cast(?
as
numeric($p,$s))),unreconciled_credit_amount_magnitude=(unreconciled_credit_amount_magnitude+cast(?
as numeric($p,$s))) where account_id=?
And the error thrown is as below.
org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement
*** expected “long”;
The *_magnitude columns have type DECIMAL(14,2)
in DB and BigDecimal
in Java. The dialect used is H2Dialect.
The jdbc url is as given below
jdbc:h2:mem:mydb;NON_KEYWORDS=year;MODE=MySQL;DATABASE_TO_LOWER=TRUE;DB_CLOSE_DELAY=-1
What could be the reason?
Thanks.