I am attempting to make custom reverse engineering templates for Hibernate. In many of the templates I see online, I see variables such as pojo, class, c2j. My question is where are these variable coming from ? I can tell that the oft-mentioned pojo is a BasicPOJOClass entity but I can't seem to be able to find all of the variables available to a template.
For example, here is a ftl found on the web from some version of hibernatetools.
<#if ejb3>
<#if pojo.hasIdentifierProperty()>
<#if property.equals(clazz.identifierProperty)>
${pojo.generateAnnIdGenerator()}
<#-- if this is the id property (getter)-->
<#-- explicitly set the column name for this property-->
</#if>
</#if>
<#if c2h.isManyToOne(property)>
<#--TODO support @OneToOne true and false-->
${pojo.generateManyToOneAnnotation(property)}
<#--TODO support optional and targetEntity-->
${pojo.generateJoinColumnsAnnotation(property, cfg)}
<#elseif c2h.isCollection(property)>
${pojo.generateCollectionAnnotation(property, cfg)}
<#else>
${pojo.generateBasicAnnotation(property)}
${pojo.generateAnnColumnAnnotation(property)}
</#if>
</#if>
Just by reading the template, you know there are variables available to you such as cfg, clazz, c2h and ejb3 but you have no idea of w开发者_Go百科hat they are and what methods on them are available to you. Any help is greatly appreciated.
I think most of the FreeMarker root context setup is handled in the AbstractExporter and GenericExporter classes. It looks like there are a couple of variables available, e.g.
- artifacts
- c2h
- c2j
- cfg
- clazz
- exporter
- outputdir
- pojo
- template_path
If everything else fails you'll have to dig through those source files in order to find out about their meanings...
HTH.
精彩评论