From the course: Creating Spring Boot Microservices
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Transaction rollback - Spring Boot Tutorial
From the course: Creating Spring Boot Microservices
Transaction rollback
- [Instructor] So we got a message from our project manager that there was a little requirement that was missed. And she said we need a service to create more than a batch tour rating for many customers. So if any tour rating for any customer already exists, then the entire request should fail. So they want to have an endpoint for creating a rating for several customers, and the request body would just have a list of customer IDs. But it's also noted that if any of the customer IDs in the list, if there's already a rating for that customer ID, then the whole request should fail. And so this brought back something that we didn't do, and that is dealing with transactions and database rollbacks. So in 6_02, here is this new public method that I've created in TourRatingService, which will rate many, so passing in a tour ID and a score and a list of customers, and it will verify the tour and then iterate through the customers, and before it actually creates a rating for that customer…