Creating a JPA application

The following are the typical steps in creating a JPA application:

  1. 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.
  2. Create persistence.xml and specify the database configurations.
  3. Create entities and relationships.
  4. Get an instance of EntityManagerFactory by calling Persistence.createEntityManagerFactory.
  5. Create an instance of EntityManager from EntityManagerFactory.
  6. Start a transaction on EntityManager ...

Get Java EE 8 Development with Eclipse now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.