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.
  1. 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
  2. Convert the BookRepository class to a GenericRepository class that provides CRUD operations for any entities.
  3. Add the new entity classes to the persistence.xml configuration file and update the SQL script with the test data.
  4. Run the CustomerRepositoryIT and the OrderRepositoryIT integration tests.