Spring Applications
Exercise: Book Entity
The objective of this exercise is to implement a book entity and a repository with CRUD operations.
- Create and start a PostgreSQL database
bookstore
.
- Implement a
Book
class and add JPA annotations to make it an entity class that conforms to the given SQL schema.
- Implement a
BookRepository
class that creates an entity manager and implements CRUD operations for the Book
entity.
- In the
persistence.xml
configuration file define the persistence unit bookstore
which maps the Book
entity to the bookstore
database.
- Add the property
jakarta.persistence.sql-load-script-source
with the value META-INF/data.sql
and save the SQL script with the test data in the corresponding folder.
- Run the BookRepositoryIT integration test.