標籤:div odi use pop 派生 使用 eve png conf
Hibernate Tools的官方網站:http://hibernate.org/tools/
Step1、安裝好Hibernate Tools,建立一個Dynamic web project,工程名為“test”。
Step2、以Mysql為樣本,建立相應的測試資料庫及表,如下所示:
[sql] view plain copy
- mysql> use test;
- Database changed
- mysql> show tables;
- +----------------+
- | Tables_in_test |
- +----------------+
- | customer |
- | login |
- +----------------+
- 2 rows in set (0.10 sec)
Step3、將MySql的Jdbc驅動庫(mysql-connector-java-5.0.8-bin.jar)拷貝至lib目錄。
Step4、利用Hibernate Tools產生Hibernate的cfg.xml。如:
直接預設轉到下一步的配置介面,配置如:
點擊完成(Finish)後,它將產生如下xml的設定檔(hibernate.cfg.xml):
[html] view plain copy
- <?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">org.gjt.mm.mysql.Driver</property>
- <property name="hibernate.connection.password">[email protected]</property>
- <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
- <property name="hibernate.connection.username">root</property>
- <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
- </session-factory>
- </hibernate-configuration>
Step5、利用Hibernate Tools產生Hibernate的Console配置。如:
點擊完成(Finish)後,它將組建組態檔案,如:
Step6、利用Hibernat Tools產生Hibernate的reveng.xml配置。如:
直接預設轉到下一步的配置介面,配置如:
點擊完成(Finish)後,它將產生如下xml的設定檔(hibernate.reveng.xml):
[html] view plain copy
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE hibernate-reverse-engineering PUBLIC
- "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
- <hibernate-reverse-engineering>
- <table-filter match-catalog="test" match-name="customer" />
- <table-filter match-catalog="test" match-name="login" />
- </hibernate-reverse-engineering>
Step7、最後一步了,產生對應檔和Java代碼。如:
點擊運行(Run)後,它將產生如下對應檔和Java代碼檔案,如:
參考:http://www.cnblogs.com/abllyboy/archive/2010/12/23/1914577.html
Hibernate Tools for Eclipse的使用