enumsjaasopenxava

How to save enum actual value with Openxava?


I have Enum as below.

private Sex sex; public enum Sex { MALE, FEMALE, OTHER }

Openxava save the values database as 0,1,2. But I want to save actual values like "MALE","FEMALE" and OTHER.

How can I do this with Openxava?

I have some enums with more values not only this enum.

I am using shared database and if I save the values as 0,1,2 other applications going to fail.

AND

How can I add the blank element in drop down list 0 position and user cannot select the empty value.

please help me to fix this issue...

Thank you...


Solution

  • Use @Enumerated(EnumType.STRING):

    @Enumerated(EnumType.STRING)
    private Sex sex;
    

    This not specific of OpenXava, it's a JPA feature.