Spring Framework - JPA, Hibernate and JDBC

This post outlines the difference between JPA, Hibernate and JDBC. They are essential to know to work with database in Spring Framework and Springboot projects.

JPA (Java Persistence API):
JPA is a Java specification that defines an object-relational mapping standard for Java applications. It provides a higher-level abstraction over JDBC, but defines a set of interfaces and classes that ORM frameworks like Hibernate can implement. JPA introduces a set of annotations and a query language (JPQL) that developers can use to map Java objects to database tables and execute queries.

Hibernate:
Hibernate is an Object-Relational Mapping (ORM) framework for Java that simplifies the interaction between Java applications and relational databases by implementing JPA specifications and concepts. It provides a higher-level abstraction over JDBC, allowing developers to work with Java objects instead of directly writing SQL queries. Hibernate maps Java classes to database tables and automatically handles tasks like generating SQL queries, executing them, and mapping result sets back to Java objects.

JDBC (Java Database Connectivity):
JDBC is a low-level Java API that provides a standard way for Java applications to interact with relational databases. It defines a set of interfaces and classes that allow developers to execute SQL statements, retrieve and process result sets, and manage transactions. With JDBC, developers must write a significant amount of low-level code (SQL query codes) to handle database operations, such as establishing a connection, creating statements, mapping result sets to Java objects, and managing resources like connections and statements.

Link To A Good Post Details More …