Batch hint
utdrewJan 16 2009 — edited Jan 28 2009Hi,
I'm trying to select multiple objects in a query and apply the batching hint to the query. This fails at runtime with an IllegalArgumentException because it is only applicable if you are returning 1 object. My problem is that the number of objects produced can be quite large and then as I iterate over them, relationships are fetched one at a time which really bogs down. Is there a way to stipulate that the entity manager fetch associations for a multi-object select? I've also played with the @JoinFetch annotation which gives the desired query but then results in a later exception when the results are being associated with the entities.
Here is a sample of how I would like to write the query:
SELECT new org.comp.MC(med1, med2)
FROM FM med1, FM med2
JOIN FETCH med1.nM JOIN FETCH med2.nM
LEFT JOIN FETCH med1.st LEFT JOIN FETCH med2.st
WHERE med1.mi = med2.mi
Thx Drew