Assume
I have a parent entity "A" and child entities "B", "C", "D" and "E"
One to Many mapping is defined with fetch type as eager for all the child entities of A which is - "B", "C", "D" and "E"
B, C, D, E are tied with Many to One - "P" entity
Now when i get the "A" entity...all is being loaded and the below query takes a huge time
FROM A ORDER BY pkey DESC
After retrieving the "A" entity..I will iterate the B and get the "P" primary key from the same. similarly i need all the primary keys of "P" associated with "B", "C", "D" and "E"
Is it possible to write any HQL to get only the primary keys without loading the entire entities without considering or bypassing the annotations which is already defined with fetch type as eager?
Can we change the fetch type as eager to lazy, execute separate queries for each entity to get the values?
Does adding a batch size to fetch type as eager would be fruitful?
Could you please suggest how we can approach on the three and what would be the best approach to resolve this issue?
Thanks.