-->
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: HQL Without using alias
PostPosted: Thu May 12, 2005 2:37 pm 
Newbie

Joined: Thu May 12, 2005 2:28 pm
Posts: 2
Hibernate version: 3.0.1

Name and version of the database you are using: Oracle 10g

If I use HQL and forget to use an alias on the joined class, then the sql generated adds an extra join with this table for any condition on it. If i have the HQL
select count(*) ,sum(movs.mtoOpe)
from ClassTotal actual left join actual.movimientos movs
where movs.fchOpe > :fchMax
group by actual.codEmp,actual.codCen

The generated query is OK. But, in my first attempt, I wrote
select count(*) ,sum(actual.movimientos.mtoOpe)
from ClassTotal actual left join actual.movimientos movs
where actual.movimientos.fchOpe > :fchMax
group by actual.codEmp,actual.codCen

And the generated query was:
select sum(movimiento2_.mto_ope) as col_2_0_, count(*) as col_3_0_
from total almsdomens0_ left outer join movements movimiento1_ on
almsdomens0_.cod_emp=movimiento1_.cod_emp and
movements movimiento2_, movements movimiento3_
where almsdomens0_.tip_mov='S' and
almsdomens0_.cod_emp=movimiento3_.cod_emp and
almsdomens0_.cod_emp=movimiento2_.cod_emp and
movimiento3_.fch_ope>?
group by almsdomens0_.cod_emp , almsdomens0_.cod_cen

(Note the movements after the join condition)

I dont know if it is a bug, and, anyway, the workaround is easy (to always use an alias) but this point made me spent a lots of hours and I think it would be useful for another person.

Regards.


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.