I have a cascade queries from distinct tables/views/joins/whatever from my some SQL DB to process outer requests to my service.
One request is dependent on another.
For example, to process the purchase order I have the next queries:
- select for order and its properties;
- select all bills queued for this order;
- select for payments for this order;
- select for items in order;
- select customer's selected item variants for each item in order;
- select possible shipment companies;
- et cetera...
How could I select data from SQL database in distinct queries, and all of them return data in one round-trip?
The simple way is to join everything and doing row-mapping denormalized data from ResultSet to DTO objects. But there is additional overhead to aggregate fetched result with distinct entities along with consistency check (and this this computational complexity increased as O(n^m) where m is equal to entities count).
Traditional approach makes all total JDBC-queries for the one request to my service to look as weird staircase on Gantt chart :(