dev-blog

Sunday, January 23, 2005

Hibernate enums deprecated

One charachteristic of enumerations is that they are static. They possible enumerated values cannot be changed at run time. If the allowed values should be changeable it's problably not an enumeration but more a separate entity.
Enumerations are that static that their values are known when coding against them.

Hibernate does provide a method to persist enumerations. Nevertheless the Java Interface PersistentEnum is depricated
I found some suggestions for how to persist enumerations with hibernate:

  1. UserType per EnumType

  2. Extend PersistenEnum usertype

  3. A Forum Article


  4. Go for the non type save way and just use public static final int or String values

I'll check the first option by trying to map jakarta-commons-lang enums with hibernate. (I'll also have to check how this will behave in future with Java 5 enums)
Results will be posted here as soon as possible

0 Comments:

Post a Comment

<< Home