Probably not best described in the title but i have 3 entities
Order -> OneToMany -> OrderProduct
and
OrderProduct <- ManyToOne -> Product
Product <- OneToMany -> OrderProduct ,
my native query that works is
SELECT t0.*
FROM isc_orders t0
INNER JOIN isc_customers t1 ON t0.ordcustid = t1.customerid
INNER JOIN isc_order_products t2 ON t0.orderid = t2.orderorderid
INNER JOIN isc_products t3 ON t2.ordprodid = t3.productid
where t3.productid in (359, 344, 345, 346, 347, 348)
is there any way to do this in a JPA way in a single select as I have my collections and and entities eager loading with join so that the object graph is populated on one pass
Something like this:
Note that you need two joins with
OrderProducts – one for filtering, another for eager fetching.