|
Currently, when IntegerTypeDescriptor encounters database NULL value, it calls provided JavaTypeDescriptor's .wrap(...) method with 0 parameter. This is problematic for 2 reasons:
-
JavaTypeDescriptor might try to convert 0 to something meaningful unnecessarily (e.g. as CalendarTypeDescriptor would do if it expected a timestamp as plain number in the database)
-
the value returned from wrap() will be ignored anyway in BasicExtractor.extract() after rs.wasNull() is consulted
-
JavaTypeDescriptor might do some conversion where 0 is not valid input; it would like to throw exception (or log error) on invalid input, but it can't – it's normal that it's called on invalid input
proposed solution
In IntegerTypeDescriptor replace
return javaTypeDescriptor.wrap(rs.getInt(name), options);
with
int value = rs.getInt(name);
if (rs.wasNull()) {
return null;
} else {
return javaTypeDescriptor.wrap(value, options);
}
+ same for other SqlTypeDescriptor-s that work on primitives, like BigIntTypeDescriptor
|