I have my rowmapper like:
private static final class UserRowMapper implements RowMapper<User> {
User user = new User();
user.setId(rs.getInt("id"));
user.setUserType( (UserType)rs.getInt("userType")); // ?????
return user;
}
So I am trying to cast the integer value in the db for userType to the enumeration UserType.
Why doesn’t this work?
Cast it? No, can’t be done.
You can call valueOf to get the Enum value from the String, as long as the String is valid.