I have enum class
package org.testTask.DTO;
public enum Publisher {
MOSCOW("МОСКВА"),
ST_PETERSBURG("ПИТЕР"),
O_REILLY("O’REILLY");
private String name;
private long id;
Publisher(final String name) {
this.name = name;
this.id = ordinal();
}
public String getName() {
return name;
}
public long getId() {
return id;
}
}
SQL request
protected Publisher getObject(ResultSet resultSet) throws SQLException {
return Publisher.valueOf(resultSet.getString("NAME"));
}
and variables in the database with values "МОСКВА", "ПИТЕР", "O’REILLY". But it gives me an error java.lang.IllegalArgumentException: No enum constant org.testTask.DTO.Publisher.ПИТЕР
I can't understand what the problem is.