Having a hibernate mapping a legacy database I want to use EnumTypes to map certain columns that contain string constants with whitespace to some Enum class.
The mapping:
@Entity
@Table(name = "OPERATOR")
public class Operator {
@Id
@Column(name = "ID")
private Long id;
...
@Enumerated(EnumType.STRING)
@Column(name = "STATUS")
private Status status;
...
}
public enum Status {
OPERATOR_CREATED("Operator created"),
ACTIVE("Active"),
END_DATED("End dated");
private String name;
Status(String status) {
name = status;
}
}
As you can see we can't us the database values straight as the enum names, as there are white spaces in them.
I was wondering if it is possible to use enums for this?