I am using reverse engineering and I have a table:
this_thing ( other_thing_id INT PK, this_thing_type ENUM('ASDF','QWER') PK, ... other fields)
In my hibernate.reveng.xml I have the following stanza:
<table name="this_thing"> <column name="this_thing_type" type="com.asdf.qwer.ThisThingType"> <meta attribute="annotations">@javax.persistence.Enumerated(javax.persistence.EnumType.STRING)</meta> </column> </table>
I have altered the PojoPropertyAccessors.ftl to emit "annotations":
<#if pojo.hasMetaAttribute(property, "annotations")> ${c2j.getMetaAsString(property, "annotations")} </#if>
The Enumerated annotation is placed on the getId() method of the ThisThing Entity instead of on the getThisThingType() method of the ThisThingId Embeddable class.
I have been using this approach successfully for other enum properties, but this is the first time the property has been part of the primary key.
a.) Is this a bug in the handling of meta attributes when the property is part of the key? b.) Is there a workaround? c.) Is there a better way to generate the Enumerated attribute for String-based enum values?
|