Enumerations in Hibernate

using hibernate or JPA annotations:

class User {
   @Enumerated(EnumType.STRING)
   UserType type
}

UserType is just a standard java 5 enum.

I can’t imagine this is just limited to just annotations but I don’t actually know how to do this with hbm files. It may be very version dependant, I’m guessing but I’m pretty sure that hibernate 3.2+ is required.

edit: it is possible in a hbm, but is a little messy, have a look at this forum thread

Leave a Comment