The second midterm will cover the key concepts in JPA: entity classes, service classes, and repositories.
For the exam I will give you some controller methods and some DTO classes and ask you to write the entity classes, repositories, and a service class to make everything work.
Here is the problem that I gave for the second midterm in a previous iteration of this course.
For that exam I allowed students to use a computer to type out their work, so this exam problem involves more work than the problem you will see on the midterm. For our midterm you will be writing code out by hand, so the exam problem will be shorter and simpler than the problem below.
Every summer Wisconsin hosts a number of major music festivals, including SummerFest in Milwaukee, Mile of Music in Appleton, and Eaux Claires in Eau Claire. You have been asked to build a system that will make it easier for fans to find performances by their favorite artists at one of these festivals.
For this exam problem we will work with three entities: artists, venues, and performances.
Artists will have an id number, a name, and a genre. Venues will have an id number, a name, and an address. Performances will have an artist, a venue, a start time and an end time.
Click the button above to download the starter project for this exam. This project contains code for controller classes and DTOs. Your job will be to write the remaining classes and interfaces needed to get everything working.
The starter project I have provided contains a couple of controller classes. In those classes you will find methods to support these actions:
You will need to construct the Entity classes for this project and the Repository interfaces to go with them.
For this exam problem you will need just one service class. I have set up that class for you. You will need to add all of the methods needed to make the service class work. Note that I have already written code in the controller classes that calls methods in the service class - you will need to write the code for those methods.
Note also that the code in the controller classes is set up to handle exceptions that the service methods may throw. Your job will also include having those service class methods throw the appropriate exceptions when things go wrong.
I have already configured the starter project to use Spring Data. I have also configured the application.properties file to work with a database named festival. All you will need to do is to create a new, empty database with that name in MySQL. When you run your application for the first time your server will automatically create all of the necessary tables in the database.
To help you get started I have already provided three DTO classes in the starter project.
When a client posts an artist they will supply the name and genre for the artist. The system will generate an id for the artist automatically and return that id in the ArtistDTO in the response.
When a client posts a venue they will supply a name and an address for the venue. The system will generate an id for the venue automatically and return that id in the VenueDTO in the response.
To post a performance, the client will supply the id number of the artist, the id number of the venue, a start time, and an end time in the PerformanceDTO they post to you.
When a client requests a list of performances for an artist you should include the artist name and the venue name in the PerformanceDTO objects you return as a result.
Click the button below to download my solution for this sample problem.