How do I map an enum with a field in it?
public enum MyEnum{
HIGHSCHOOL ("H"), COLLEGE("C")
private int value;
public MyEnum getInstance(String value){...}
}
@Entity
public class MyEntity {
@Enumerated(...)
private MyEnum eduType;
}
How do I annotate so that values H, C will be persisted in the database? If I keep @Enumerated(EnumType.STRING)
, HIGHSCHOOL instead of H will be stored in the database. If I use EnumType.ORDINAL
, 1 instead of H will be stored in the database. Kindly suggest a solution.