These files implement a solution I found on this link :
http://appfuse.org/display/APF/Java+5+Enums+Persistence+with+Hibernate
It uses @Type Hibernate annotation to define the mapping between enumeration and database. Note it is a Hibernate specific solution, as it looks there is no equivalent feature in JPA for the moment (and I hope there will be the equivalent in the future !).
Note thes files are not a patch to EJB3 cartridge but just templates I use with merge location features of AndroMDA.
You have to add these properties to EJB3 namespace in andromda.xml :
<property name="mergeLocation">${conf.dir}/cartridge/ejb3/custom</property>
<property name="mergeMappingsUri">file:${conf.dir}/mappings/EJB3MergeMappings.xml</property>
Then copy :
- templates to "/mda/src/main/config/cartridge/ejb3/custom/templates/ejb3" directory
- EJB3MergeMappings.xml file to "/mda/src/main/config/mappings" directory
As suggested by Vance on the forum, I added a test on $hibernateExtensionEnabled, so that this feature is enabled only if Hibernate is enabled.
GenericEnumUserType.vsl is the same as posted earlier.
Other templates + cartridge.xml file are supplied as diff files.
Added a from method to look for enumeration literal having a given value for a member variable. This method is generated only if member variable attribute has <<Identifier>> stereotype.
More details here :
http://galaxy.andromda.org/forum/viewtopic.php?p=26077#26077
Sorry ... Forgot to say the patch was in enumeration.vsl.fromMemberVariable.diff attached file.