A sample Java project demonstrating JPA/Hibernate usage in a library management context.
- Understanding JPA Entity relationships
- Working with JPA repositories
- Managing database transactions
- Implementing domain models
- Writing unit tests for persistence layer
- Java Development Kit (JDK) 21
- Maven 3.9+
- Your favorite IDE (VS Code, IntelliJ IDEA, or Eclipse)
- Git
-
Clone the repository:
git clone https://github.com/ebpro/sample-jpalibrary.git cd sample-jpalibrary -
Build the project:
./mvnw clean verify
-
Run the application:
mvn exec:java -Dexec.mainClass="fr.univtln.bruno.samples.jpa.App"
src/
├── main/
│ ├── java/
│ │ └── fr/univtln/bruno/samples/jpa/
│ │ ├── model/
│ │ │ ├── documents/
│ │ │ ├── users/
│ │ │ └── utils/
│ │ └── App.java
│ └── resources/
│ └── META-INF/
│ └── persistence.xml
└── test/
└── java/
└── fr/univtln/bruno/samples/jpa/
- JPA Entity relationships (OneToMany, ManyToOne, ManyToMany)
- Inheritance mapping
- Identifiers and primary keys
- Data generation for testing
- Lombok usage for reducing boilerplate
- Follow the existing package structure
- Use Lombok annotations to reduce boilerplate
- Write unit tests for new features
- Document your code with Javadoc
- Follow Java naming conventions
- Using H2 database launch in application.
- Database console available at
http://localhost:8082 - Using H2 in-memory database for testing
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.