vifeng / TicketToTheMoon

WIP: Ticket office website. back office for venues to operate their shows and front office to buy tickets for the public.
1 stars 0 forks source link

19 reading database or json converting request error #21

Closed vifeng closed 10 months ago

vifeng commented 10 months ago

Major Update : Controller & Service for Ticket_Reservation is working but not complete (I did the find, findById, Create). It might need some refactoring, see below:

I encountered two bugs :
1. I added some setters to the composite key because the generated implementation uses the empty constructor then uses the setters to set the values.
2. **Implementation order :** In mapstruct the generated implementation uses the empty constructor then uses the setters to set the values. The orders of the setters is not guaranteed. So if you have a setter that depends on another setter, you can't be sure that the other setter has been called. One of the solution is to use custom mapping method and use the builder pattern. Another Solution would be to validate the entity object in the service layer instead of the setters. On this version, I have decided to go with the builder solution. It is working smoothly **but it might need a refactoring for a better solution**.
For example see the configurationHall.java and its mapper (see `setCapacityOfConfiguration()`, Hall has to be already defined because we call one of his variable to check against a value of the current object).