Forums Register Login

Hibernate - Enum

+Pie Number of slices to send: Send
I'm dealing with some model classes with some fields that have been declared as enum's. Allis well and happy in my little application world - _however_ we are not the sole users of the database and as such, other status's may appear in those enumerated fields.

Using @Enumerated(EnumType.STRING) with the proper enum type causes an exception. In a number of places we've had to change them to String fields and define final static values for comparison.

Thoughts / ideas on a solution that would allow my application to treat them as Enum's yet fail gracefully (eg: default value / skip record ... ) ?

Thanks,
+Pie Number of slices to send: Send
Maybe you can use an approach simmilar to this to handle this situation.

You can make the nullSafeGet method to check if the enum value is defined.
[ July 24, 2008: Message edited by: Rodrigo Lopes ]
Have you no shame? Have you no decency? Have you no tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 3978 times.
Similar Threads
enum equivalent in java
Mapping Enum to field � the old way
JComboBox with enum
Java Enum factoring common functionalities.
Mapping filed to custom Enum
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:16:17.