Hibernate Tools for Eclipse的使用

來源:互聯網
上載者:User

標籤: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  
  1. mysql> use test;  
  2. Database changed  
  3. mysql> show tables;  
  4. +----------------+  
  5. | Tables_in_test |  
  6. +----------------+  
  7. | customer       |  
  8. | login          |  
  9. +----------------+  
  10. 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  
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!DOCTYPE hibernate-configuration PUBLIC  
  3.         "-//Hibernate/Hibernate Configuration DTD 3.0//EN"  
  4.         "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">  
  5. <hibernate-configuration>  
  6.     <session-factory>  
  7.         <property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>  
  8.         <property name="hibernate.connection.password">[email protected]</property>  
  9.         <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>  
  10.         <property name="hibernate.connection.username">root</property>  
  11.         <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>  
  12.     </session-factory>  
  13. </hibernate-configuration>  

Step5、利用Hibernate Tools產生Hibernate的Console配置。如:




點擊完成(Finish)後,它將組建組態檔案,如:

Step6、利用Hibernat Tools產生Hibernate的reveng.xml配置。如:

直接預設轉到下一步的配置介面,配置如:

點擊完成(Finish)後,它將產生如下xml的設定檔(hibernate.reveng.xml):

[html] view plain copy  
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <!DOCTYPE hibernate-reverse-engineering PUBLIC   
  3.     "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN"   
  4.     "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >  
  5. <hibernate-reverse-engineering>  
  6.     <table-filter match-catalog="test" match-name="customer" />  
  7.     <table-filter match-catalog="test" match-name="login" />  
  8. </hibernate-reverse-engineering>  

Step7、最後一步了,產生對應檔和Java代碼。如:

點擊運行(Run)後,它將產生如下對應檔和Java代碼檔案,如:


參考:http://www.cnblogs.com/abllyboy/archive/2010/12/23/1914577.html

Hibernate Tools for Eclipse的使用

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.