First i am using java and postgress as my Database.
i want to create a method that get All the orders and there specific fields:
orderId,
customerId,
List<Appetizer>,
List<Entree>
The first image i am able to do that. But the problem is that i have an N+ 1 issue because of my loop.
Scenario: imagine that you want to get All the orders in a Restaurant. You go to the restaurant and ask for orderId:1 you get which appetizer & entree that come with orderId:1. Then you go back to your table but you still need to get the rest of the orders that you want.(That is the N+1 issue that i am having with my loop.).
I need to find a way to go to the restaurant once to find all the appetizers &
then going to the restaurent for the second time to find all the entrees
how can i do that ?
if you need anymore infomation plz tell
Thank you for your time.