James,
I am not entirely sure of all the problems that you are encountering .....
Have you looked at defining your own UserType.
This UserType could map a null in your java class to a 0 when writing to the database and vice versa when reading.
If you have a look at the topic "Handling Dates in a Legacy System" (in the forum) you will see the fun and games I have had trying to cope with an empty string representing Null in a date field.
Fortunately, I do not think your problems are nearly so bad .......
You would need to modify the sqlTypes to integer:
Code:
public int[] sqlTypes() {
return new int[] { Types.INTEGER };
}
You would also have to modify the nullSafeGet() and nullSafeSet():
Code:
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
integer val = rs.getInteger(names[0]);
if (null == val)
return(null);
if (val == 0)
return(null);
return val;
}
You would have to do the reverse for the nullSafeSet (I have not included the code as I would probably get it wrong first time !!!!!)
I do not think that you would have to alter deepCopy as it appears to use nullSafeGet and hence a 0 would already been changed to a Null.
Obviously you would have to later your table mapping to use the newly created UserType.
Hope this helps,
Mike.