-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: join without fetching in HQL (or with Criteria API)
PostPosted: Thu Nov 09, 2006 10:34 am 
Newbie

Joined: Thu Nov 09, 2006 10:23 am
Posts: 2
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 13, 2006 10:57 am 
Newbie

Joined: Thu Nov 09, 2006 10:23 am
Posts: 2
Class DistinctRootEntityResultTransformer is filtering duplicates. So i am using it:
List result = new DistinctRootEntityResultTransformer().transformList(criteria.list());

But i don't think this is the solution, number of results from database can be huge.

What i find strange is that the generated content of the SQL SELECT clause depends on what is in the WHERE clause. It should be independant to me...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.