Data persistence with Open Liberty

Data Persistence is a means for an application to persist and retrieve information from a non-volatile storage system. Persistence is vital to enterprise applications because of the required access to relational databases.

Persistent data is data that outlives the application process that created it. Applications commonly persist data in relational databases, which organize data in sets of tables with columns and rows. Many different types of relational databases exist, and their configurations vary. Enterprise applications must manage persistence themselves or use third-party solutions to handle database updates and retrievals with persistence

JPA and JDBC

The Java Database Connectivity API (JDBC) handles the actual communication between an application and the tables in a relational database by managing SQL queries and commands. The Jakarta Persistence API (JPA) provides a level of abstraction between the application and JDBC layers, allowing developers to manage persistence with Java annotations or XML, without having to worry about the details of SQL functions. Although managing persistence at the JDBC level provides more flexibility and fine-grained control over how data is persisted, it is much more complex to configure and maintain.

Whether you manage persistence through JPA or directly with JDBC depends on the needs of your application. Developers might prefer to work directly with JDBC if their application doesn’t have much interaction with a database or doesn’t need to support many different database vendors. However, working directly with JDBC requires familiarity with SQL. Developers who are not familiar with SQL, or whose applications need to support complex data models or multiple database vendors, might choose to manage persistence with JPA.