I know if I have an enum like this:
Code:
public enum MyEnum {
Y ("Y"), N ("N");
String value;
MyEnum (String value) {
this.value = value;
}
}
It works fine when I annotate a field with @Enumerated(UserType.STRING)
The "Y" or "N" gets automatically saved/loaded to database
But what if I wanted it to be like:
Code:
public enum MyEnum {
YES ("Y"), NO ("N");
String value;
MyEnum (String value) {
this.value = value;
}
}
This no longer works, because when it's trying to save to database for example if I use MyEnum.YES It actually is trying to save "YES" not the value of "Y"
Any way to work around this?