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.
- Java 17
- PostgreSQL
- JPA & Hibernate
- JUnit 5
- DAO Design Pattern
- Environment Variables for DB Connection
- 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.
- ✔️ 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.).
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.
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
andJPAProduct
; - Test isolation and exception handling ensured across all DAO layers.
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
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.