public void nullSafeSet(PreparedStatement ps, Object obj, int index) throws HibernateException, SQLException { if (obj == null) { // Note: units.sqlType shouldn't be used since this // doesn't actually get registered with the PG driver // (apparently). Instead we use the official Types.OTHER ps.setObject(index, null, Types.OTHER); } else { ps.setObject(index, units.todbvalue(obj), Types.OTHER); } }