The attached testcase is similar to
that shows a JPQL query:
SELECT a FROM Author a WHERE :lastName IS NULL OR LOWER(a.lastName) = :lastName
Hibernate crashes in case where the parameter value is null:
org.hibernate.exception.DataException: could not execute query
Caused by: java.sql.SQLDataException: An attempt was made to get a data value of type 'VARBINARY' from a data value of type 'VARCHAR'.
I would expect that this type of query succeeds, because an equivalent raw JDBC testcase (included) succeeds also.
String sql = "SELECT ID, NAME, region_id FROM CUSTOMERORDER WHERE ((? IS NULL) OR (region_id = ?))";
PreparedStatement pStmt = conn.prepareStatement(sql);
Integer regionId = null;
ResultSet result = pStmt.executeQuery();
For some background, please see
"Add support for setObject(<arg>, null)"
which is included since db-derby-10.7.1.1
It would be great to see an early assessment in case this is a database driver issue not Hibernate.