Use of Hibernate Tools for Eclipse

Source: Internet
Author: User

The official website of Hibernate tools: http://hibernate.org/tools/
Step1, install hibernate Tools, build a Dynamic Web project named "Test".
Step2, with MySQL as an example, set up the corresponding test database and table as follows:

[SQL]View PlainCopy 
    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, copy the MySQL JDBC Driver Library (Mysql-connector-java-5.0.8-bin.jar) to the Lib directory.
Step4, using hibernate tools to generate Hibernate cfg.xml. Such as:

Directly by default go to the next configuration interface, configuration such as:

After clicking Finish, it will generate the following XML configuration file (Hibernate.cfg.xml):

[HTML]View PlainCopy 
  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. < name="Hibernate.connection.username">root</ Property >
  11. <property name="Hibernate.dialect">org.hibernate.dialect.mysql5dialect</ Property>
  12. </session-factory>
  13. </hibernate-configuration>

Step5, use hibernate tools to generate the Console configuration for hibernate. Such as:




When you click Finish, it generates a configuration file, such as:

Step6, use hibernat tools to generate reveng.xml configuration for hibernate. Such as:

Directly by default go to the next configuration interface, configuration such as:

After clicking Finish, it will generate the following XML configuration file (Hibernate.reveng.xml):

[HTML]View PlainCopy 
  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, the last step, generate the mapping file and Java code . Such as:

After clicking Run, it will generate the following mapping files and Java code files, such as:


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

Use of Hibernate Tools for Eclipse

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.