DEV Community

Zakaria Abdelali
Zakaria Abdelali

Posted on • Edited on

WTH is JDBC, Spring JDBC, JPA, Hibernate, ORM, Spring Boot JPA

Evolution of Database Access in Java

This article explains how Java database access evolved step by step:
JDBC → Spring JDBC → JPA → Hibernate → Spring Boot JPA

Each step fixes problems from the previous one.


1. JDBC (Java Database Connectivity)

JDBC is the basic and lowest-level way for Java to talk to a database.
You control everything manually.

Features

  • JDBC Driver (a bridge between Java and the database)
  • Connection (opens a connection to the database)
  • Statement (executes SQL queries)
  • PreparedStatement (precompiled SQL, safer and faster)
  • ResultSet (holds the data returned from the database)
  • Full control over SQL
  • Works with many databases

Problems

  • Too much repeated code
  • Must manually open and close connections
  • Error handling is hard
  • SQL mixed with business logic
  • Hard to maintain large projects

Solution

JDBC works, but it is too low-level.
We need something simpler.


2. Spring JDBC

Spring JDBC simplifies JDBC.
Spring manages connections and errors for you.

Features

  • Less boilerplate code
  • Automatic resource management
  • Cleaner exception handling
  • Still uses SQL
  • Easier than plain JDBC

Problems

  • Still writing SQL manually
  • Manual mapping from rows to objects
  • Database logic still visible everywhere

Solution

Developers want to work with objects, not tables.
This leads to ORM.


3. JPA (Java Persistence API)

JPA is a standard for ORM (Object Relational Mapping).
It defines how ORM should work, not how to implement it.

Features

  • Maps tables to Java objects
  • Standard API (same rules everywhere)
  • Reduces SQL usage
  • Database independent

Problems

  • JPA is only rules, not real code
  • Cannot run alone
  • Needs an implementation

Solution

Use a JPA implementation like Hibernate.


4. Hibernate

Hibernate is a JPA implementation.
It actually does the ORM work.

Features

  • Automatic SQL generation
  • Object-based database access
  • Caching support (store data in memory for faster access)
  • Lazy loading (load data only when needed)
  • Database independent
  • Very powerful and flexible

Problems

  • Heavy configuration
  • Hard for beginners
  • Too much setup for small projects
  • Performance issues if used incorrectly

Alternatives to Hibernate

  • EclipseLink (official JPA reference implementation)
  • OpenJPA (Apache project)
  • MyBatis (SQL-focused, not full ORM)

Solution

Hibernate is powerful, but needs simplification.
Spring Boot solves this.


5. Spring Boot JPA

Spring Boot JPA combines:
Spring Boot + JPA + Hibernate

Focuses on simplicity and speed.

Features

  • Auto configuration (no manual setup)
  • Uses Hibernate by default
  • Easy repository pattern
  • Clean and readable structure
  • Production ready

Problems

  • Less low-level control
  • Some behavior is hidden by auto configuration

Solution

Best choice for modern applications.
Use lower levels only when needed.

For more details:

Top comments (0)