I'm trying to convert a grails-project to the playframework. In Grails you can define an id so the the id will be stored in the database (see Enhanced Enum Support in the release notes). I saw a similar question, but with no acceptable solution. If I change the type the CRUD-module get a problem, because the information that a Enum should be shown is lost.
So I wonder if there exists a nice solution with play, which based on Hibernate. Perhaps with hacking the JPAPlugin?
[Update 1] I started to try the second solution with @type
-annotation. Unfortunately this become broken with hibernate 3.6 (which is used by play 1.2.2). TypeFactory.basic()
is not available any more. But following the documentation I can't find a work around.
[Update 2] There was a solution for hibernate 3.6.1, but it's really clumsy to define the type at each usage of enum.
@Type(type="hibernatehelper.GenericEnumUserType",
parameters= {
@Parameter(
name = "enumClass",
value = "models.Geschlecht"),
})
public Geschlecht geschlecht = Geschlecht.WEIBLICH;