- Build your data model
- chose your database – I used postgres but hibernate can connect to most db
- create DDL for the db and create schema and table. Make sure schema and user that is accessing the data are different. Many developer makes mistake of using schema id as the user which poses many issues if the user who is accessing the data is different
- validate the tables and relationships are correct
- Pick your tool for development. I have been using eclipse which has database and JPA plugins. I have used other IDE also; however, due to the richness of plugin, eclipse is still the most useful IDE>
- Install database plugin and JPA plugin. You need database plugin to connect to database for JPA. Also it is a good plugin to work with database
- connect to the database
- create a new JPA project
- Now fun begins – right click on the JPA project or use File->new->other, then open the JPA, choose “JPA Entities from Tables” and click Next. YOu will see many choices and configurations. Configure as per you need. You can also select interface or abstract class.
- Generate the class. You have JPA annotated java classes. Normally, I use JPA project to generate the JPA models which are then I copy to actal package in my application project.
NOTE: – Above task used to take one database and one developer at least month for a simple database. If it were a trading system, it would have taken 3 -4 months of work. Now, if you have good data model to create which may take a one person 2 – 4 weeks, the code generation is in seconds instead of month effort.