2

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...

user3496599
  • 1,207
  • 2
  • 12
  • 28
  • Found a solution to save the enum value in database with @Enumerated(EnumType.STRING) annotation. How can I set the first element is empty and validate if user does not select the enum value. – user3496599 Nov 30 '15 at 16:10

1 Answers1

1

Use @Enumerated(EnumType.STRING):

@Enumerated(EnumType.STRING)
private Sex sex;

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

javierpaniza
  • 677
  • 4
  • 10