Eclipse automatically generates annotation entities from JPA

Source: Internet
Author: User

Hibernate is one of the most common implementations of JPA, and hiberante itself supports annotation syntax. Now don't look at that heap of XML mappings anymore. And Eclipse also provides tools to generate the entity class directly from the database.

I. Project Add JPA tool

Now add the existing project to JPA support, first select project right properties->project Facets tick list project Facts under JPA option, OK to select Transfer to database connection configuration

>> Click Furhter Configuration Available

Platform Select Generic, JPA implements type select Disable library configuration because the required jar files have been placed in the Lib directory under Web-inf. So do not configure. Again the following connection this is necessary to configure.

Second, configure the data connection

To add a database connection, select an Oracle database for example:

Determine the configuration information.

III. Configuration item JPA build entity

above configuration complete, right-click on the project folder to select JPA tools->generate entities from Tables. After:

Choose the built connection if you don't have connect, connect. will be as shown (sometimes eclipse will have some small problems to see the table, you can restart the test, it is not possible to build a JPA project directly, create the entity and then copy to your own project.) Select the table for which you want to generate the entity, Next:

above is the relationship between the tables, if you can make the corresponding changes (using Ecipse 3.5 looks like eclipse3.4 has not this function, Eclipse is getting stronger), and then next, such as:




iv. removal of unnecessary error warnings

Eclipse automatically generates annotation entities from JPA

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.