-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate 4.1.7 BUG - Unneeded join on hibernate SQL
PostPosted: Wed Dec 26, 2012 11:41 am 
Newbie

Joined: Thu Dec 20, 2012 7:09 am
Posts: 1
After upgrading Hibernate from 3.2.4 to 4.1.7 we are facing some unneeded joins that are, in some cases, compromising performance. Let's show an example:

Let's say we have the following bidirectional one-to-many relationship : A (1)----->(*) B

Whenever we write an hql like this, hibernate makes two joins with the same entities (note that the HQL has a.b in projection)

- HQL

- select a.b from A a where a.b.name = 'entity_B'

- SQL result

select b1_.id as id1_, b1_.name as name1_
from
A a0_inner join B b1_ on a0_.b_id=b1_.id
cross join B b2_ <----------- unneeded join
where
a0_.b_id=b2_.id <----------- unneeded join
and b2_.name='entity_B'



Hibernate 3.2.4

It generate the SQL as expected (note that the HQL has a.b.id in projection)


- HQL

- select a.b from A a where a.b.name = 'entity_B'

- SQL result

select
b1_.id as id0_,
b1_.name as name0_
from
A a0_
inner join
B b1_
on a0_.b_id=b1_.id
where
b1_.name='entity_B'




Its look like the problem is happening with the join, locate after the where, which is causing the colateral effect on the sql generator.

It is not a critical bug it may impact in performance. Hope you fix this in next releases to make hibernate better than it is already is.


Thanks in advance


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

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.