日期:2014-05-16 浏览次数:20521 次
它支持Eclispe插件方式和Ant方式。这里主要将采用Ant方式。这样可以脱离Eclipse :)
1 准备好Hiberbate.cfg.xml .主要是告诉工具取哪的数据库和表格
< ?xml version="1.0" encoding="UTF-8"?>
< !DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
< hibernate-configuration >
< session-factory>
< property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver< /property>
< property name="hibernate.connection.password">tt< /property>
< property name="hibernate.connection.url">jdbc:oracle:thin:@10.1.248.23:1521:tt< /property>
< property name="hibernate.connection.username">tt< /property>
< property name="hibernate.default_schema">tt< /property>
< property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect< /property>
< /session-factory>
< /hibernate-configuration>
2 编写Ant脚本。这一步是要定义ant任务,以及生成POJO和HBM.XML配置文件
< taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.class.path" />
< target name="hibernatecode">
< hibernatetool destdir="E:\gg\yy\3123\src">
< jdbcconfiguration configurationfile="E:\gg\yy\3123\build\hibernate.cfg.xml" packagename="com.tt.wss.hibernate"
/>
< hbm2java>
< hbm2dao>
< /hibernatetool>
< /target>
< target name="hibernatehbm">
< hibernatetool destdir="E:\gg\yy\3123\src">
< jdbcconfiguration configurationfile="E:\gg\yy\3123\build\hibernate.cfg.xml" packagename="com.asia.wss.hibernate"
/>
< hbm2hbmxml>
< /hibernatetool>
< /target>