First let us setup the development environment. Download this document and follow the step by step instruction to install the necessary software’s.
We are going to create POJO from the existing database in mysql. So let us download driver for the same. You can download the driver here
Step 1:
In the Eclipse, Select File –> New –> Other->JPA Project
Click Next
Enter the Project Name and leave all the other options as default and click Next.
Click Next
For JPA Implementation Type , select Disable Library Configuration
Next click Add connection, Select mysql
Click Next
Select New Driver Information next drivers drop down.
Select MYSQL 5.1 and goto JAR List tab. Add the Connector zip file which we downloaded earlier.
Click ok and Test your mysql connection in the following screen.
After testing the connection, you can click finish and come back to starting screen
Now you can click finish button to create the project with the connection information.
Now click on the Project Name and Right Click, Select New –> JPA Entities from the Tables
It will show all the tables in the connected database. You can choose all the tables and Click Next
You can verify all the foreign key relationship. In this example, i do not have more than one table, so it is empty. Click Next
Here you can Key Generator as Identity and you can modify/leave to default for other properties.Click Next
Click Next and Click Finish
Now You can see all the POJO classes are created with the relationship.
No comments:
Post a Comment