Hello
I have multiple entity (I don't own the tables) that have properties that represent a Boolean value as either '1' (true) or null (false) in the database (Oracle 10g).
I wrote an EnhancedUserType which works great for the most part.
The only problem I am experiencing is when I want to do a HQL query for false values.
Example:
Code:
from MyEntity where propertyWithMyType = false
It works when searching for true values but when searching for false I don't know what to put in the objectToSQLString method.
Returning an empty string or null doesn't work.
Code:
public String objectToSQLString(Object value) {
return ((Boolean) value ) ? "'1'" : "?????"; // I don't know what to put here for the false value
}
I checked the SQL that gets created and it seems the value returned from objectToSQLString() is placed on the right-hand side of an equals sign (=) in the query. This doesn't seem to work for null values (If I manually run the query on the database but replace the '=' with 'is' it works).
I am using Hibernate 3.5.1-Final.
Any ideas what I can do to let the queries work correctly for false(null in the database) values?