The Java Persistence API (JPA) provides Java developers with an object/relational mapping facility for managing relational data in Java applications. Java Persistence consists of four areas:

  • The Java Persistence API
  • The query language
  • The Java Persistence Criteria API
  • Object/relational mapping metadata

In other words, it allows to interact with a database as plain Java objects by introducing a layer between the application logic and the database interaction. As an added benefit you can switch databases with minimal changes. In 95% of the cases, just add the proper database Java driver and update the configuration and there you go.

JPA, if configured to do so, can even create the tables in the database and/or update those tables as the model evolves.

For data migrations I use Flyway.

Learning Trail: