Dolphin Exercise
This exercise begins where the tutorial on JPA relations 1:1 and 1:m ends.
- Video tutorial
- Source code for this exercise. This one can be cloned if you haven’t done your own coding along with the tutorial.
The Domain model below shows the entities from the tutorial. Those are sketched in black ink (Person
, PersonDetail
, and Fee
). Now the board of the Dolphin swim-club have asked for an extra use case:
US-1: As a administrator I would like to be able to add notes to each person, so we can keep track of important information. Each note contains a brief text, the date of creation, and the person who entered the note.
The new user story is added to the domain model in red.
- Please consider how to implement US-1 - and do it.
- Add a few notes to each person, and check that they are persisted correctly in the database.
- Create a DolphinDAO and implement basic CRUD operations. At least enough to persist some test data.
- Write Unit tests to make sure that everything works.
Now the board wants more:
US-2: As an administrator I would like to be able to get the total amount paid for a given person. US-3: As an administrator I would like to be able to get a list of all notes for a given person
- Implement US-2
- Implement US-3
Make us proud ;-)
Now we got the full attention of the board - and they want more:
US-4: As an administrator I would like to get a list of all notes with the name and age of the person it belongs to.
- Implement US-4. Hint: you might want to use what is called a DTO projection to make handling query output easier.