java - Hibernate enum mapping -


I need to map the enums which can not implement the interface from the already existing database, which can be used in the same table Stores @Enumerated (EnumType.STRING) .

  class A {As the owner class using the name of HasName; } Interface name {string matching (); } Enum X implies HasName {John, Mary; Public string getName () {return.name (); }} Enum Y uses HasName {Tom, Ann; Public string getName () {return.name (); }}  

How should mapping be controlled in this case? To implement the interface all the values ​​do not change the database as separate values, but I'm not sure how objects should be retrieved from DB (I need a custom mapper, What is enum using a specified ANM classes? Does this Hibernate basically support this functionality?).

It is possible custom UserType (such as) and use it from its mapping

  & lt; Property name = "type" no-null = "true" & gt; & Lt; Type name = "at.molindo.util.hibernate.EnumUserType" & gt; & Lt; Param name = "enumClass" & gt; Com.example.MyEnum & lt; / Param & gt; & Lt; / Type & gt; & Lt; / Property & gt; Edit: Hibernate comes with its own enumatype (in hibernate annotation since 3.2, since 3.6 in the hibernate-core - it is not in hibernate-annotation at the time of writing, but see). 


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -