Hello,
I'm receiving an Oracle error when attempting to execute a native SQL query that uses a null parameter value. I've boiled it down to this test case:
Code:
final String SQL = "select username as userName from all_users where username = NVL(?, username)";
SQLQuery sqlQuery = getSession().createSQLQuery(SQL);
sqlQuery.setParameter(0, null);
List results = sqlQuery.list();
As you can see, the query uses Oracle's NVL function to handle null parameters.
However, when I run this code, it fails with an error on the
sqlQuery.list() call. The error is as follows:
Code:
org.hibernate.exception.GenericJDBCException: could not execute query
...
...
Caused by: java.sql.SQLException: ORA-01465: invalid hex number
For some reason it doesn't like a null parameter, which should be valid and legal. If I use a string value for the parameter it works fine, but for some reason it doesn't like a null value.
I'm using Hibernate 3.2.6.ga and Oracle 10, along with ojdbc14.jar as the Oracle driver.
Any hints or suggestions? This is pretty critical for me as I'm trying to use it in a reporting framework.
Thank you!!!
-Ryan