引用的 Freemarker Hibernate 类位于哪里
我正在尝试为 Hibernate 制作自定义逆向工程模板。在我在网上看到的许多模板中,我看到了诸如pojo、class、c2j之类的变量。我的问题是这些变量来自哪里?我可以看出经常提到的 pojo 是一个 BasicPOJOClass 实体,但我似乎无法找到模板可用的所有变量。
例如,以下是在网络上从某个版本的 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>
只需阅读模板,您就知道有可用的变量,例如 cfg、clazz、c2h 和 ejb3,但您不知道它们是什么以及它们的哪些方法可供您使用。非常感谢任何帮助。
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 what they are and what methods on them are available to you. Any help is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为大部分 FreeMarker 根上下文设置都是在 AbstractExporter 和 GenericExporter 类。看起来有几个可用的变量,例如
如果其他一切都失败,您将不得不挖掘这些源文件以找出它们的含义...
HTH。
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.
If everything else fails you'll have to dig through those source files in order to find out about their meanings...
HTH.