I have an Order which has a collection of OrderLines. Every OrderLine has a many-to-one to a Product. For all Orders I have a searchwindow which - by default - shows all Orders in a grid. Using this same window I can filter all Orders which contain a given Product. Our customer generates about 700 Orders per day and orders have an average of about 35 lines.
In the searchwindow I only show information stored within the Order object itself. But, if I filter for a specific Product, it will initialize my lazy loaded relationship to the collection of OrderLines as well as the many-to-one to my Product within my OrderLine. Each orderline is queried line by line, and for each line there is a seperate query to the product table.
so on average I get 35 queries per order to initialize all the OrderLines, plus 35 queries to fetch the products associated with that orderline.
What is the best way to load all orderlines and their associated product at once (and if not possible all orderlines per order)? I know I can map my many-to-one to the product in the orderline as a fetch="join", but that will still leave me with the 35 single queries to get the orderlines+products.
FYI: Currently I load everything lazy.
Any suggestions? Can I use Future here?
Regards, Ted