I've been all over the place, but still seem to be lost on the best way to persist enum values that have string representations.
Code:
public enum Codes
{
LATE("L"),
ON_TIME("OT"),
EARLY("E"),
Unknown("U")
String codeValue;
Codes( String cv)
{ codeValue= cv; }
public String valueOf() { return codeValue; } // or whatever here
}
Code:
@Entity
public class ...
{
private Codes code;
...
@Column(name="code")
@Enumerated(EnumType.STRING) // not what I'm after
public getCode()
{
return code;
}
}
Using that as the enum, I want to be able to persist the values of the enum instead - Enumerated(EnumType.STRING) simply puts the enum itself as a string, not the assigned value of that enum (LATE vs. L)....
Maybe I'm asking to much of it ;) I have looked around so much and am still pretty clueless about this scenario. I have seen some very complicated examples of custom enum type classes, etc, but nothing that is any clearer than, well, mud![/code]