-->
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: One join too many?
PostPosted: Fri Nov 21, 2003 8:36 am 
Newbie

Joined: Thu Nov 06, 2003 8:28 am
Posts: 8
I have a bidirectional many-to-many between Folder and Record and a class Test that extends Record.
Following HQL
Code:
select test.stringfield from Test test join test.folders folder where folder.id=?

creates following SQL
Code:
select test0_.stringfield as x0_0_ from S_Test test0_ inner join Record test0__1_ on test0_.id=test0__1_.id inner join folder_records folders1_ on test0_.id=folders1_.record_id inner join Folder folder2_ on folders1_.folder_id=folder2_.id where (folder2_.id=? )

Isn't the join on the collection table folder_records enough?
Maybe it is not possible for Hibernate to figure out that the join on Folder is not needed?

PS: In fact the join on Record is also not needed, but I can imagine that leaving that one out would make things too complex.
Ivo Houbrechts


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 21, 2003 8:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Try:


Code:
select test.stringfield from Test test where ? in elements( test.folders )



and see if it as faster (if you have subqueries available).


Otherwise you would have to sue a composite element instead.


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.