My spring boot project is structured so that i have modules contract (that handles incoming requests) and impl (that deals with the logic). Contract has a facade that passes the request to a facade in impl, that passes it to a service class, which is where the logic resides.
Using the repository pattern, structuring my code so that first i get the data, then i process it, how would i do that if for example, i had a list of orders coming in the request, and had to add the total amount which i get from the database using query a, then the item from query b? My struggle is, if i'm getting all data first, and then processing it, how do i know that item x belongs to the order x, considering i'm working with a list?
I have tried doing a foreach, and getting all the data for each order, and then building it, but that way i'm mixing the part where i get all the data and, and process it.