I have a cool line 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 apply an integer value in db for userType to a UserType enumeration.
Why is this not working?
Drop it? No, it cannot be done.
You can call valueOf to get the Enum value from String if the string is valid.
You can index in Enum.values() :
Enum.values()
user.setUserType( UserType.values()[rs.getInt("userType")] );
You might want to check out some errors. :)
Source: https://habr.com/ru/post/1392398/More articles:How to use isspace function in C ++? - c ++How can I stop the fake game from failing to verify the uniqueness of a ruby ββusername on rails? - ruby ββ| fooobar.comDelayed run_at not working at the right time - ruby-on-railsdummy movups created by gcc - optimizationSaving SQLPLUS to file - sqlSet maximum C # memory usage - c #Is there a tool that will replace Excel file transfer back and forth and merging? - javaDistributed Objects, Threading, Objective-C - multithreadingWhat is the complete Teradata Client software? - teradataR / Zoo: show a tick every year on the x - r axisAll Articles