JPA is the Java Persistence API. It is the mechanism where we
can create database transactions using POJO ( Plain-Old-Java-Objects ). But however, We need to import the Java Persistence libraries called javax.persistence.*
To create a JPA we need the following:
1. entity class ( the exact database table representation )
2. persistence.xml file ( this file creates the database connection )
3. Another class where you can insert, update, or find an entity.
This class will be using the entity class.
( In this case the entity is a mirror of the database table entries )
But JPA is just a specification, ( just like REST in as described in my previous entry ) Hibernate is an implementation of JPA ( and so is several other implementations )
In Hibenarate it relates to these following files, just like how we can create JPA
1. entity class ( the exact database table representation , but no more annotations )
2. hibernate.cfg.xml – similar to the persistence.xml ( or see link )
3. *.hbm.xml – the entity configuration ( all column table’s specifications are set here )
4. classes that insert, update, and do DB transactions – You may use hibernate libraries only, or a Spring-hibernate library can be used.
NOTE: there is a certain naming convention used in hibernate in its entity class, so it must follow the setter/getter naming convetion to successfully bind to the other hibernate configurations
See here for a detailed JPA example: