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
Complete the above configuration, right-click on the project folder to select JPA tools->generate entities from Tables. After:
Choose a built-in 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 where you want to generate the entity, Next:
The above is the relationship between the tables, if you can make the corresponding changes (using Ecipse 3.5 seems to eclipse3.4 not yet this function, Eclipse is getting stronger), and then next, such as:
(This seems to be the Eclipse 3.5 added) can see it. You can change it as needed, but not much. And next.
After, such as:
This is the adjustment of each property of some tables, and generally does not have to be tuned. The finish is good.
iv. removal of unnecessary error warnings
Eclipse automatically generates annotation entities from JPA