To improve performance I've had to implement an eager get method in my DAO. Here is the HQL:
Code:
select distinct all bs from BookStatement bs left join fetch bs.authorLines bsal left join fetch bs.pages bsp left join fetch bsp.themes bspt left join fetch bsp.memoLines bspml where bs.id IN (:ids)
The relationships are lists (and lists in lists) and I get many many duplicates in the results. The distinct only appears to work for the root object (as does the result transform trick). Is there a way to make all the collections only contain distinct values?
I've tried (Hibernate 3 legacy) criterias and I can't get the eager loading on the nested (list in a list) relationships to work. I can't see how to specify distinct results either.
Only changing the lists to sets in the model seems to work - and that screws up the ordering of the elements.
Changing the collections to eager is not an option because it cripples performance in the rest of the application that only needs a tiny bit of the (lazy) loaded object.
Any ideas?