I am trying to implement a FreeMarker custom reverse engineering template that automatically creates my Hibernate classes.
In the build process, the template is used by hibernate-tools to generate the hibernate classes.
So far, I am using the default freemarker templates for that purpose and it works fine.
But now I am facing the questing:
How do I add additional properties to the default getter-annotations?
The default freemarker method for One-to-may associations is (implemented in Ejb3PropertyGetAnnotation.ftl):
...
<#elseif c2h.isCollection(property)>
${pojo.generateCollectionAnnotation(property, cfg)}
...
The generated java code is for example:
@OneToMany(fetch=FetchType.LAZY, mappedBy="person")
public Set<ContactInformation> getContactInformations() {
return this.contactInformations;
}
But I want to add cascade = CascadeType.ALL to each one-to-many getter annotation like this:
@OneToMany(cascade = CascadeType.ALL
fetch=FetchType.LAZY, mappedBy="person")
I am new to freemarker and hibernate and have no idea how to archive this.
Thanks a lot for your help!