Hibernate Tools以Ant Task方式运行,主要在Build.xml中配置。内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<project name="University_FG" default="all" basedir=".">
<!-- "." represents the src folder -->
<!-- Declare path variables to refer the third party libraries required-->
<path id="toolslib">
<path location="./lib/hibernate-tools.jar" />
<path location="./lib/hibernate3.jar" />
<path location="./lib/freemarker.jar" />
<path location="./lib/mysql.jar" />
<path location="./lib/mysql-connector-java-5.1.7.jar" />
<path location="./lib/dom4j-1.6.1.jar" />
<path location="./lib/log4j-1.2.15.jar" />
<path location="./lib/slf4j-api-1.5.6.jar" />
<path location="./lib/slf4j-jdk14-1.5.6.jar" />
<path location="./lib/commons-logging-1.1.jar" />
</path>
<!-- To include the src and lib names in the path -->
<path id="mypath">
<fileset dir="./lib">
<include name="**.*" />
</fileset>
</path>
<!-- Declare the HibernateToolTask -->
<target name="all">
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="mypath" />
<!-- Declare the destination directory -->
<hibernatetool destdir="./src">
<!-- Declare Classpath -->
<classpath>
<path location="./config" />
</classpath>
<!-- Declare the configuration file path -->
<configuration configurationfile="./config/hibernate.cfg.xml">
</configuration>
<!-- Convert the mapping file to Java source files -->
<hbm2java/>
<!-- Convert the mapping file to DDL files -->
<hbm2ddl export="true" outputfilename="university_sql.ddl" />
</hibernatetool>
</target>
</project>
build.xml的内容有两部分:
第一部分是Path,主要是引入所需要的Jar包
第二部分是Hibernate Tools的相关配置。
hibernatetool属性
属性名称 |
定义 |
使用情况 |
destdir |
生成文件的输入目录 |
Required |
templatepath |
用户编辑模板的路径 |
Optional |
classpath |
解析资源时的依赖环境 |
Optional,但通常是要求 |
property(and propertyset) |
控制输出的属性设置,大部分与用户定义模板提供属性有关。 |
Optional |
configuration
(annotationconfiguration, jpaconfiguration,
jdbcconfiguration)
|
必须为Hibernate元模型指定四个属性之一。 |
Required |
hbm2java(hbm2cfgxml,
hbmtemplate, etc.)
|
指定一个或多个的输出方式 |
Required |
本例中就有两种输出方式:
一种是根据Mapping生成POJO文件,一种是根据Mapping生成DDL,并生成数据库表。
分享到:
相关推荐
利用hibernate-Tools里的相关工具类,使得java实体类(POJO)、hbm映射文件、数据库表(Schema)之间可以相互转化。也就是说,只要有其中一样,就可以通过各种途径得到其它两样。如果手里已经有了其中一样东西,要想...
HibernateTools-3.2.4,Hibernate工具包,开发使用,欢迎下载
hibernate tools源码运行修改需要的jar 源码下载地址是http://anonsvn.jboss.org/repos/hibernate/tags/TOOLS_3_2_4_GA/
Eclipse 在线配置 Hibernate Tools
Hibernate Tools is a toolset for Hibernate implemented as an integrated suite of Eclipse plugins, together with a unified Ant task for integration into the build cycle. Hibernate Tools is a core ...
eclipse 配置 hibernate tools 反向生成 pojo类 注解
下载并安装hibernate tools插件,下载地址:...安装完Hibernate tools插件后,在eclipse安装目录下搜索并替换hibernate-tools-5.2.0.Beta1.jar文件,即可生成带中文注释的类和hbm文件
HibernateTools-3.2.4.Beta1-R200810311334.zip
hibernatetools eclipse下的hibernate插件
Hibernate Tools 3.2.0 beta 8Hibernate Tools 3.2.0 beta 8
eclipse下使用hibernate tools实现hibernate逆向工程时 生成实体类时可以自动添加数据库中的注释
hibernatetools-Update-4.1.1.zip
解压,将links和myplugin文件夹,放在这个E:\eclipse-jee-juno-SR2-win32\eclipse下,对应位置写在hibernatetools.link文件中,用记事本打开。这是我的位置。你的位置改变,你要重写hibernatetools.link中的路径。 ...
Hibernatetools_Reference_Guide
今天研究了半天如何安装使用hibernate tools,整合了一下网上下载的资料,给大家看看
HibernateTools Hibernate配置文件生成 映射文件生成 POJO生成
hibernate-tools.jar
Ant打包和Hibernate文件生成实例,Ant打包和Hibernate文件生成实例
Hibernate Tools for Eclipse Plugins 的安装和使用