'how to get ENUM variable with JPA
I have a model with an ENUM field defined as:
@Enumerated(EnumType.STRING)
@Column(name = "CLASSIFICATION", length = 25)
private ClassificationEnum classification;
ClassificationEnum is defined as:
public enum ClassificationEnum {
Type1,
Type2,
Type3;
}
On repository class, when I try to get the model with Type2 classification, I got the following error:
No enum constant [...].ClassificationEnum.2
The 2 is also the id of the class that contains my enum (maybe it's not related), but I don't know why JPA is trying to access my enum that way.
Solution 1:[1]
You should write the enum class like this:
public enum ClassificationEnum {
Type1,
Type2,
Type3
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Md. Samim hossain |
