Primer on Building Java Persistence using Hibernate

    1. Build your data model
    2. chose your database – I used postgres but hibernate can connect to most db
    3. 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
    4. validate the tables and relationships are correct
    5. 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>
    6. 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
    7. connect to the database
    8. create a new JPA project
    9. 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.
    10. 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.
    11. 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.