Hibernate Tools 的使用

Hibernate Tools 的使用

由于myEclipse 6.5的Hibernate 反向映射 生成的XML配置文件 很难得到令我满意的XML文件
所以今天开始使用HibernateTools 这个工具


1.首先在 www.eclipse.org/downloads/ 中下载  Eclipse IDE for Java EE Developers (190 MB)   如图:



记住一定是Eclipse JavaEE的版本

2.在http://www.hibernate.org/subprojects/tools.html 下载Hibernate tools  如图


直接 点击Latest relase 3.2.4GA 即可下载

3.开始安装Hibernate tools插件
解压HibernateTools-3.2.4.GA-R200905070146-H18.zip  得到features 和 plugins
将两个文件夹中的内容分别放入eclipse目录下名字相同的文件夹下
重启eclipse
4.新建一个Java工程  file --->new ---> java Project

5.file--->new--->others --->Hibernate


点击next

点击next 配置hibernate.cfg.xml文件

new 一个新的数据库连接 



next    配置Database Connection  Name 改为myOracle


next

finish

finish

生成了hibernate.hbm.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 name="sessionFactory">
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">CI_DEMO</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@perf-ps:1521:orcl</property>
<property name="hibernate.connection.username">CI_DEMO</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
</session-factory>
</hibernate-configuration>

找到hibernate的一个小图标 选择Hibernate Code Generation Configurations...


new 一个New_configration(1)  填写相应的信息

点击setup  create new


点击refresh  刷出表 选择要配置的表   finish!!!

点击Exporters




配置要生成的文件 我选的是javaBean 和hbm.xml文件
Apply  close

打开生成的hibernate,reveng.xml



选择table  保存




运行 (点击1.New_configuration)



OK  XML和JAVA 生成了



猜你喜欢

转载自duguyiren3476.iteye.com/blog/1555217
今日推荐