To all the Hibernate developers and other gurus out there ...
There seems to be a bug (Hibernate 3.6.10) that generates a totally unnecessary join from an HQL query:
Code:
/* select
new GroupSummary(
count(theWebTestSessionQuestion.testSession),
theWebTestSessionQuestion.group,
sum(theWebTestSessionQuestion.pact),
sum(theWebTestSessionQuestion.pmax))
from
WebTestSessionQuestion theWebTestSessionQuestion
group by
theWebTestSessionQuestion.group */ select
count(webtestses0_.WQSQ_WQSID) as col_0_0_,
webtestses0_.WQSQ_GROUP as col_1_0_,
sum(webtestses0_.WQSQ_PACT) as col_2_0_,
sum(webtestses0_.WQSQ_PMAX) as col_3_0_
from
WWW_QTSQ webtestses0_,
WWW_QTS webtestses1_
where
webtestses0_.WQSQ_WQSID=webtestses1_.WQS_LFDNR
group by
webtestses0_.WQSQ_GROUP
The Criteria API does get it right, though, and produces the simple SQL I expect:
Code:
/* criteria query */ select
count(this_.WQSQ_WQSID) as y0_,
this_.WQSQ_GROUP as y1_,
sum(this_.WQSQ_PACT) as y2_,
sum(this_.WQSQ_PMAX) as y3_,
this_.WQSQ_GROUP as y4_
from
WWW_QTSQ this_
group by
this_.WQSQ_GROUP
Any suggestions or comments? Do I have to alter the HQL in some way or other?