Using Hibernate 3.3.1, I'm having problems inserting or selecting either empty or null values with Oracle. This seems to occur in both SessionImpl and StatelessSession, though I'm working mainly with Stateless. Queries that work fine with MSSQLServer are not in Oracle 10g. Example:
(SessionImpl & HQL)
Code:
_sessionImpl.createQuery("SELECT o FROM Object o WHERE o.language=:myLanguage").setParameter("myLanguage", locale.getLanguage()).list();
where .getLanguage() returns a zero length string -- ""
(or the same thing in StatelessSession & SQLQuery)
Code:
SELECT language FROM Table where field = ""
The above queries work with SQLServer but return no records in Oracle unless I explicitly add a space:
Code:
SELECT language FROM Table where field = " "
And inserting/updating like this works in SQLServer:
Code:
UPDATE Table SET field =:myValue
(where :myValue is any java object with a value of NULL)
But with Oracle throws:
java.sql.SQLException: ORA-00932: inconsistent datatypes: expected NUMBER got BINARY
I have adjusted the Dialect to use both of the following classes with no difference.
org.hibernate.dialect.OracleDialect
org.hibernate.dialect.Oracle9Dialect
What am I missing here? I thought Hibernate and the JDBC driver would manage these cases.
Thanks!