So this is what I ended up doing in the user type:
define a public static final DateTime ZERO_DATE_TIME = new DateTime(0);
and translate that as zero when converting to database:
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { if (value == null || value == ZERO_DATE_TIME) { st.setInt(index, 0); } else { doInstanceCheck(value); DateTime cal = (DateTime) value; st.setInt(index, getDate(cal)); } }
So in the query is just set to this special date and it seems to work.
|