Unknown data type when using an integer over NamedParameterJDBCTemplate on H2 [SPRING-BOOT]
This exception appears to arise because H2 is trying to type-check the statement at compile time and can't uniquely determine the type of the parameter: it could be a date or it could be a number, or perhaps something else.
The workaround (provided in the GitHub issue I raised) is to replace
SYSDATE - ?
with
SYSDATE - CAST(? AS INTEGER)
I've checked this and it works on both H2 and Oracle.