版本选择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 |