I have a class with two many-to-many associations. After reading the AR docs I realised that I'm allowed to get only one collection at a time using eager loading. So how is it possible to get a list of objects with both initialized collections for each object using eager loading and DetachedCriteria?
So far...
DetachedCriteria dc = DetachedCriteria.For(); dc.SetResultTransformer(new DistinctRootEntityResultTransformer()); dc.SetFetchMode("ComplaintCause", FetchMode.Eager); dc.SetFetchMode("InsuranceType", FetchMode.Eager); dc.SetFetchMode("Applicants", FetchMode.Eager); // MANY-TO-MANY COLLECTION
Now I would like to get another collection:
dc.SetFetchMode("Insurers", FetchMode.Eager); // THE ADDITIONAL COLLECTION TO EAGER LOAD
This gives me a strange cartesian product.
How to use a MultiQuery or MultiCriteria to get the results with both initialized collections?