in the nullSafeGet() method you use
if (!resultSet.wasNull()) {
result = Enum.valueOf(clazz, name);
}
Which works in terms of the <em>name</em> of the enum instance; however,
in the nullSafeSet() method you use
preparedStatement.setString(index, value.toString());
which calls toString() on the enum object (if I understand what's going
on correctly). Unless I'm missing something, the class as written will
fail for any enum where the result returned by name() doesn't match up
with the result returned by toString(), because what it reads from the
database won't match what it writes. |