Spring Applications
Exercise: Order Entities
The objective of this exercise is to define the relationships of the order classes and to implement a generic repository with CRUD operations.
- Add JPA annotations to the order classes such that the entities conform to the given SQL schema by defining
- the
id fields are generated primary keys
- the
address and creditCard fields of the Customer and Order entity as embedded relationships
- the
book field of the OrderItem entity as many-to-one relationship
- the
customer and items fields of the Order entity as many-to-one and one-to-many relationships with appropriate cascade and fetch types
- Convert the
BookRepository class to a GenericRepository class that provides CRUD operations for any entities.
- Add the new entity classes to the
persistence.xml configuration file and update the SQL script data.sql with the test data.
- Run the CustomerRepositoryIT and the OrderRepositoryIT integration tests.