Lab 11
[valid 2025-2026]
Java Persistence API (JPA)
Continue the application from lab 10, by using JPA (Java Persistence API) / Spring Data JPA in order to communicate with a relational database.
The following information should be stored in the DB: players, questions, games, results.
The main specifications of the application are:
Compulsory (1p)
- Use a JPA implementation (EclipseLink or Hibernate or Open JPA) with or without Spring Data JPA
- Define the entity classes for your model (at least one) and put them in a dedicated package.
You may use the IDE support in order to generate entity classes from database tables.
- Define repository clases for your entities (at least one).
- Test your application.
Homework (2p)
- Create all entity classes and repositories.
- Implement properly the one-to-many and many-to-many relationships.
- Use at least one read query based on a specific JPQL string and one transactional, modifying query.
- Log the exceptions and the execution time of your JPQL statements (you should write the log messages both on screen and in a file).
- Implement an audting mechanism for tracking changes in your database.
Advanced (2p)
- Use Criteria API / Specification to implement a dynamic search for results, with multiple optional filters
(e.g., "find results of players with names staring with ..., that have obtained more than ... points, at games that have the ... property ")
- Implement second-level caching and query caching and measure read performance improvements.
Use a micro-testing or benchmarking library, such as JMH, for measuring the execution time of methods.
(You need to handle JIT compilation, warm-up, and measurement accuracy correctly.)
Resources