Configure the hibernate tool in eclipse 3.4

Source: Internet
Author: User

1. download the latest hibernate tools from the official website of hibernate.org. I use the HibernateTools-3.2.4.GA version.

 

2. decompress the downloaded package. There are two packages: plugin and feasure. Copy the contents in the plugin package to the plug-in folder of Eclipse, copy the content in feasure to the feasures folder of Eclipse.

 

3. Restart eclipse and click WINDOW> show View> on the menu bar to open a new hibernate folder.

 

4. Create a new web project (select Dynamic Web project under eclipse 3.4 ). Add the relevant jar package to the Lib folder (Add the required package and database driver package for hibernate Development)

 

5. select the src directory under the project, right-click New-> Other-> hibernate configuration file (CFG. XML), select next in the pop-up window, and configure the information of the database associated with hibernate. Note that there are several items that must be filled in. They are database dialect, Driver Class, connection URL, username, and password ).

 

6. Select the eclipse drop-down menu window-> show
View-> Other-> hibernate
Ations, now you can view the hibernate Configuration window. Right-click Add configuration in the window, and edit appears.
Configuration window. Enter a name for configuration and select the current project in the project.
Click OK.

 

7. in the SRC project, there will be a hibernate. cfg. in the XML file, configure some information about the database link. If you want the gencode table to be not all databases, but the table under the Model Table partition below, you can add the following sentence

 

<Property name = "hibernate. default_schema"> your table partition name </property>

8. Right-click the eclipse toolbar, select customize perspective-> commands-> hibernate code generation, and click OK. In this way, the hibernate icon is added to the toolbar.

 

8.1 left click the down arrow on the right of the icon and select hibernate code generation deployments from the drop-down menu,
The output directory under the main tag selects the location of the generated file. Select the src directory.

 

8.2 reverse engineer from
JDBC
Connection is very important. select it. The package selects the package name for generating pojo. You can name the package as needed. Reveng. xml
Select setup-> Create New-> project name-> next-> refresh to display the table list, include the table you need for gencode. (You can include other tables next time)

 

9. Click Run. You will find that the pojo and. HBM. xml files we want are generated under the package configured with output. Copy the generated items to our real development environment and change the package path in the class. You can also change the package path.

 

Related Article

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.