val orderLines = OrderLines.filter( ol => ol.timestamp between(start,end) )
val distinctProductIds = orderLines.map(_.product_id).distinct.result
val products = distinctProductIds.flatMap ( pids => DBIO.sequence ( distinctProductIds.map ( pid => getProductDetails(pid)))
After 'running' the combined orderLines and products DBIO's the results are fine, but unfortunately this hits the order_line table twice. Is it possible to avoid that but still run within a single transaction
I guess procedural/jdbc it would come down to the following steps
- start transaction
- select ...,product_id from order_line where timestamp beween ...
- fetch resultset in memory
- get distinct product_id's from instantiated result_set
- for each pid, select .. from product_master, product_detail where product_master.product_id=pid ....
- commit transaction
I know it's easy enough to achieve the same by instantiating the orderLines slick query but that would terminate the dbio chain (transaction) and I need to avoid that
All tips welcome!
Peter