I understand that if you have nullable columns in the database that are mapped to primitives, you need to use a UserType to assign default values if the database column is null.
Implementing UserType for any classes are easy, however the required methods for the interface requires Object parameters (as shown below), and I am at a loss on how to implement this for primitives.
Code:
public boolean equals(Object x, Object y) throws HibernateException
{
return false;
}
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException
{
return null;
}
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException
{
}
public Object deepCopy(Object value) throws HibernateException
{
return null;
}
Should I implement these to accept the Integer wrapper if I want to use it on an int?
Does anyone have any idea what I should do here, or have an example?