版本選擇java
JBoss Tools Integration Stack 4.1.7.Final (最新的JDK,eclipse版本要求高)eclipse
模板數據
HIBERNATE 採起的是freemarker模板this
記錄一下context中的內容。spa
-- 版本 getContext().put("version", Version.getDefault()); -- 上下文對象引用 getContext().put("ctx", getContext() ); -- 無用 getContext().put("templates", new Templates()); -- 時間 getContext().put("date", new SimpleDate(new Date(), TemplateDateModel.DATETIME)); -- exporter 自身 getTemplateHelper().putInContext("exporter", this); -- getTemplateHelper().putInContext("c2h", getCfg2HbmTool()); getTemplateHelper().putInContext("c2j", getCfg2JavaTool()); -- 文件輸出路徑 getTemplateHelper().putInContext("outputdir", getOutputDirectory()); -- 模板路徑 getTemplateHelper().putInContext("template_path", getTemplatePaths()); -- artifacts 收集器,能夠記錄一些執行狀態屬性 getTemplateHelper().putInContext("artifacts", collector); -- hibernate 配置文件全屬性 getTemplateHelper().putInContext("cfg", getConfiguration());
還有一個擴展的propertyshibernate
if (getProperties() != null) { iterator = getProperties().entrySet().iterator(); while (iterator.hasNext()) { Entry<Object, Object> element = iterator.next(); String key = element.getKey().toString(); Object value = transformValue(element.getValue()); getTemplateHelper().putInContext(key, value); if (key.startsWith(ExporterSettings.PREFIX_KEY)) { getTemplateHelper() .putInContext( key.substring(ExporterSettings.PREFIX_KEY .length()), value); if (key.endsWith(".toolclass")) { try { Class<?> toolClass = ReflectHelper.classForName( value.toString(), this.getClass()); Object object = toolClass.newInstance(); getTemplateHelper().putInContext( key.substring(ExporterSettings.PREFIX_KEY .length(), key.length() - ".toolclass".length()), object); } catch (Exception e) { throw new ExporterException( "Exception when instantiating tool " + element.getKey() + " with " + value, e); } } } } }
能夠將property中的說有屬性都添加到context中去,會對hibernate特殊的參數進行KEY處理。code
#property的數據來源orm
protected Exporter configureExporter(Exporter exporter) { Properties prop = new Properties(); prop.putAll(parent.getProperties()); prop.putAll(properties); exporter.setProperties(prop); exporter.setConfiguration( parent.getConfiguration() ); exporter.setOutputDirectory( getDestdir() ); exporter.setTemplatePath( getTemplatePath().list() ); return exporter; }
他是來自於ANT自身任務配置,以及父輩任務配置。對象
不過Hibernate tools好像並無啓用property,因此須要本身擴展。繼承
附錄
hibernate 配置文件中meta元素列表接口
屬性 | 描述 |
---|---|
class-description | 指定描述類的JavaDoc |
field_description | 指定描述類的屬性的JavaDoc |
Interface | 若是爲true,表示生成接口,默認爲false |
Implements | 指定類所實現的接口 |
Extends | 指定類繼承的父類名 |
generated-class | 從新指定生成的類名 |
scope-class | 指定類的修飾符,默認爲public |
scope-set | 指定set方法的修飾符,默認爲public |
scope-get | 指定get方法的修飾符,默認爲public |
scope-filed | 指定類的屬性修飾符,默認爲public |
use-in-tostring | 若是爲true,表示在tostring()方法中包含此屬性 |
gen-property | 若是爲false,不會再Java類中生成此屬性,默認爲true |