The following are the typical steps in creating a JPA application:
- Create a database schema (tables and relationships). Optionally, you can create tables and relationships from JPA entities. We will see an example of this. However, it should be mentioned here that although creating tables from JPA entities is fine for development, it is not recommended in the production environment; doing so may result in a non-optimized database model.
- Create persistence.xml and specify the database configurations.
- Create entities and relationships.
- Get an instance of EntityManagerFactory by calling Persistence.createEntityManagerFactory.
- Create an instance of EntityManager from EntityManagerFactory.
- Start a transaction on EntityManager ...