I have a column in my DB table that I want to map to a Java object. I marked the highlighted column with an annotation:
@Enumerated(EnumType.STRING)
private RoleType code;
The problem is that on the DB side, with the exception of the values that interest me, there are unacceptable (in the context of the tasks that I do), so I want to map them to the Unknown types.
ADMIN ("ADMIN "),
CLIENT ("CLIENT"),
SOMEBODY ("SOMEBODY"),
UNKNOWN ("UNKNOWN");
Trying to do this, I got a Hibernate mapping error. Is it possible to map values other than 3 mentioned in the enumeration (ADMIN, CLIENT, SOMEBODY) to some default enum value (i.e. UNKNOWN) using Hibernate?
EDIT:
To make it clearer
How the values on the DB side should be displayed on the Java side:
TYPE_1 ---> UNKNOWN
ADMIN ---> ADMIN
CLIENT ---> CLIENT
SOMEBODY ---> SOMEBODY
TYPE_2 ---> UNKNOWN
SOMEBODY_2 ---> UNKNOWN