[Turn]eclipse reverse-generate Hibernate entity classes from a database with Hibernate tool

Source: Internet
Author: User

How to generate Hibernate entity class from database backwards???

1. First, use your own database Manager (data Management) in eclipse to connect to your database:

Then select the database, use Oracle here, and then give a name, such as MyOracle.

Click the button to create a new database-driven configuration.

Select the database version, which is the Oracle 10g version, and you can name it for that configuration.

Then select the appropriate database version of the jar package.

The following is to fill in the database connection configuration according to their own circumstances.

Next, complete the contents of the General tab under Properties, as well as connecting to the database, and then click the Test Connection button when you are finished configuring to connect to the database.

Then click Next, and then confirm the error, clicking Finish.

Data management will then appear myoracle Database Explorer, which changes as follows to indicate that the database configuration was successful.

2. Generating Hibernate entity classes

Open the Hibernate configurations window.

Then right-click on the Open window and click Add Configuration ...

Project Select item (test), Database connection Select the myoracle you just got (you can actually SELECT [Hibernate configured connection] Connection to the database via Hibernate configuration file, but this way does not necessarily succeed, the use of data Management alone is also not necessarily successful, the reason is not very clear, so the final adoption of data Management + Hibernate configuration file, so it's more insurance.)

Create a new Hibernate-related profile (Hibernate.properties and Hibernate.cfg.xml) anywhere within the project (test).

New hibernate.properties:

New Hibernate.cfg.xml:

After returning to the Edit configuration form, select the Common tab encoding select UTF-8, other default, click OK button

In this way, Hibernate config adds a configuration message such as

Right-click in the blank of the toolbar in the Eclipse menu bar and select Customize perspective

After the form appears, select the Hibernate Code Generation by selecting the Command Groups Availability tab in the diagram, and then click OK.

The toolbar will then appear with the corresponding button.

Click the button and select Hibernate Code Generation configurations in the diagram

Then pop up the window below, press as action, right click after select New

Pop up the form below, select the project address for the output, fill in the package name, tick reverse engineer from JDBC Connection, and create Hibernate.reveng.xml

Create Hibernate.reveng.xml:

Console Configuration Select the hibernate you just configured, click the Refresh button, the database will appear all the schema, find your database, and then include it in the right window, Then click the Finish button to finish creating the Hibernate.reveng.xml.

After returning, select the Exporters tab, tick domain code and hibernate XML Mappings, then click the Run button

The resulting results are as follows:

This completes.

[Turn]eclipse reverse-generate Hibernate entity classes from a database with Hibernate tool

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.