Skip to content

AsrielDreemurrGM/Migration_Of_JDBC_To_JPA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JDBC To JPA Migration

Esse README também está disponível em Português Brasileiro
Repository Link to JDBC Version: PostgreSQL_JDBC_CRUD

This project is a migration of a full Java backend CRUD application from JDBC to JPA (Java Persistence API), maintaining PostgreSQL as the database engine. It preserves the core structure of the original project while introducing JPA annotations, entity relationships, and integration with the persistence layer via the DAO design pattern.

🚀 Technologies Used

  • Java 17
  • PostgreSQL
  • JPA & Hibernate
  • JUnit 5
  • DAO Design Pattern
  • Environment Variables for DB Connection

📂 Project Structure

  • br.com.eaugusto.domain.jpa – JPA entity classes with annotations.
  • br.com.eaugusto.dao.generics.jpa – Generic DAO structure using interfaces and implementation classes.
  • br.com.eaugusto.dao.jpa – Specific DAO implementations and interfaces.
  • br.com.eaugusto.domain.jpa – JUnit 5 test classes covering all entities and DAO logic.

✅ Migration Progress

  • ✔️ JDBC base project imported;
  • ✔️ All entities rewritten using JPA annotations;
  • ✔️ Generic DAO implementation created with interface segregation;
  • ✔️ Full test coverage for JPAClient, JPAProduct, JPASelling, and JPAProductQuantity;
  • ✔️ Relationship mapping tested and verified (OneToMany, ManyToOne, etc.).

📄 Environment Variables

To run the project, configure the following variables in your system or IDE:

  • DB_URL – JDBC URL for your PostgreSQL database (e.g., jdbc:postgresql://localhost:5432/online_selling);
  • DB_USERNAME – Your PostgreSQL username;
  • DB_PASSWORD – Your PostgreSQL password.

🧪 Test-Driven Development

The project follows TDD principles with extensive unit and integration testing:

  • Product quantity calculations validated in JPAProductQuantityTest;
  • Sale logic and DAO integration tested in JPASellingTest;
  • All basic CRUD operations tested for JPAClient and JPAProduct;
  • Test isolation and exception handling ensured across all DAO layers.

📘 Persistence Configuration

The persistence.xml file is located in the META-INF directory and configured with the following properties:

  • Persistence Unit Name: JDBC_To_JPA_Migration
  • Provider: org.hibernate.ejb.HibernatePersistence
  • Dialect: org.hibernate.dialect.PostgreSQLDialect
  • DDL Auto: update
  • SQL Output: hibernate.show_sql = true

📝 Javadoc Documentation

The entire codebase has been documented with Javadoc to improve maintainability and comprehension:

  • ✅ All domain entities include class-level and method-level documentation;
  • ✅ DAO interfaces and implementations are fully documented, including exceptions and custom operations;
  • ✅ Generic DAO structure explained and linked using {@link} annotations for better IDE navigation;
  • ✅ All test classes now include documentation describing test purpose, coverage, and exception handling strategies.

Releases

No releases published

Packages

No packages published

Languages