Hi,
I've noticed that there is an odd behavior (at least from my point of view) in IntegerTypeHandler class:
@Override
public Integer getNullableResult(ResultSet rs, String columnName)
throws SQLException {
return rs.getInt(columnName);
}
rs.getInt(columnName) returns 0 when the column value is null:
/**
* Get the value of a column in the current row as a Java int.
*
* @param columnIndex
* the first column is 1, the second is 2,...
*
* @return the column value; 0 if SQL NULL
*
* @exception SQLException
* if a database access error occurs
*/
public int getInt(int columnIndex) throws SQLException {
This is taken from com.mysql.jdbc.ResultSetImpl.
Why isn't the implementation for getNullableResult was something like:
int result = rs.getInt(columnName);
if (rs.wasNull()) {
return null;
} else {
return result;
}
This will make IntegerTypeHandler support Nullable Integer columns, and not return the number 0 instead of NULL.