源代码分享——进化中Hibernate3脚本
在Hibernate有一些相当方便的辅助工具: hbm2java,hbm2ddl, 数据库的逆向工程,Mapping Editor.
这些任务可以通过Ant构建完成,Hibernate提供了Ant Tasks及其构建脚本.由于Hibernate从2到3进行了重大重构,且包重新做了组织,因此Ant构建脚本也发生了巨大变化.在2中脚本样式为:
<?xml version="1.0"?>
default="db" basedir=".">
<!-- Set up properties containing important project directories -->
<!-- Set up the class path for compilation and execution -->
<!-- Include our own classes, of course -->
<!-- Include jars in the project library directory -->
fork="yes">
<!-- Teach Ant how to use Hibernate's code generation tool -->
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="project.class.path"/>
<!-- Generate the java code for all mapping files in our source tree -->
description="Generate Java source from the O/R mapping files">
<!-- Create our runtime subdirectories and copy resources into them -->
<!-- Copy our property files and O/R mappings for use at runtime -->
<!-- Compile the java source of the project -->
description="Compiles all Java classes">
destdir="${class.root}"
debug="on"
optimize="off"
deprecation="on">
<!-- Generate the schemas for all mapping files in our class tree -->
description="Generate DB schema from the O/R mapping files">
<!-- Teach Ant how to use Hibernate's schema generation tool -->
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="project.class.path"/>
quiet="no" text="no" drop="no">
在3中,构建脚本为:
<?xml version="1.0" encoding="GBK"?>
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="tasks.classpath"/>
其中的delimeter属性在Hibernate-Tool 3 A5版本中不支持.
<!--
这个任务在Hibernate-Tool 3 A5版本中不支持. -->
Hibernate3构建脚本的变化
这个脚本在Eclipse中检验过.
通过这个脚本,执行了很多Hibernate辅助工具的功能,方便了开发.
在Hibernate有一些相当方便的辅助工具: hbm2java,hbm2ddl, 数据库的逆向工程,Mapping Editor.
这些任务可以通过Ant构建完成,Hibernate提供了Ant Tasks及其构建脚本.由于Hibernate从2到3进行了重大重构,且包重新做了组织,因此Ant构建脚本也发生了巨大变化.在2中脚本样式为:
<?xml version="1.0"?>
default="db" basedir=".">
<!-- Set up properties containing important project directories -->
<!-- Set up the class path for compilation and execution -->
<!-- Include our own classes, of course -->
<!-- Include jars in the project library directory -->
fork="yes">
<!-- Teach Ant how to use Hibernate's code generation tool -->
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpathref="project.class.path"/>
<!-- Generate the java code for all mapping files in our source tree -->
description="Generate Java source from the O/R mapping files">
<!-- Create our runtime subdirectories and copy resources into them -->
<!-- Copy our property files and O/R mappings for use at runtime -->
<!-- Compile the java source of the project -->
description="Compiles all Java classes">
destdir="${class.root}"
debug="on"
optimize="off"
deprecation="on">
<!-- Generate the schemas for all mapping files in our class tree -->
description="Generate DB schema from the O/R mapping files">
<!-- Teach Ant how to use Hibernate's schema generation tool -->
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="project.class.path"/>
quiet="no" text="no" drop="no">
在3中,构建脚本为:
<?xml version="1.0" encoding="GBK"?>
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="tasks.classpath"/>
其中的delimeter属性在Hibernate-Tool 3 A5版本中不支持.
<!--
这个任务在Hibernate-Tool 3 A5版本中不支持. -->
Hibernate3构建脚本的变化
这个脚本在Eclipse中检验过.
通过这个脚本,执行了很多Hibernate辅助工具的功能,方便了开发.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/374079/viewspace-131304/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/374079/viewspace-131304/