Hello,
I have troubles with join without fetching in criteria or with HQL:
My model is simple: orders linked to lineitems by one-to-many
and say I would like to get orders that have lineitems with a certain reference number:
'lineitem.reference like '%aa%' in HQL.
The problem is that i get duplicated orders, as many times there are items in these orders
since line items are also generated in the HQL (or criteria) select clause.
Of course i could filter out these duplicates but this doesn't look very clean and performant (and this is here only a simple request, only one relationship).
I use lazy="proxy" (or true) with fetch="select" on this one-to-many relation order-items,
i tried HQL with 'order inner join order.lineitems' without the 'fetch' keyword (no 'join fetch')
in the from clause but i still get line items in the generated SQL and duplicate orders.
I would have expected to get the items in a 2nd request.
I also tried without using the join keyword in HQL, by linking myself tables together by ID as in SQL, but not better.
I have tried changing hibernate.max_fetch_depth as i have seen on other post messages, no more success.
I am using hibernate 3.2ga (i also tried with 3.0.5)
and i have oracle9i.
Thanks for any clue.
|