Hello,
I am newbie in Java and Hibernate. I need to translate the following
SQL query:
select t.*, v.capacity - sum(d.weight) as capacity
from transits t
join deliveries d on t.id = d.transitid
join vehicles v on t.vehicleid = v.id
group by t.id
having capacity >= :capacityMin
... to Hibernate Query Language. I've tried with:
select t, v.capacity - sum(d.weight) as capacity
from Transit t
join t.deliveries d
join t.vehicle v
group by t.id
having capacity >= :capacityMin
But it doesn't work (no such column 'capacity'). Is there any other way
to do that?
Greetings and TIA.

Signature
Jakub Kuźma
http://jah.pl/
JID oraz e-mail w domenie gmail.com, login - qoobaa
Lew - 23 Sep 2007 17:16 GMT
> Hello,
>
[quoted text clipped - 7 lines]
> group by t.id
> having capacity >= :capacityMin
This is problematic SQL, because you are SELECTing t.* but GROUPing on t.id.
You have to use aggregate methods on all the columns that are not t.id.

Signature
Lew
Lars Enderin - 23 Sep 2007 18:19 GMT
Lew skrev:
Just checking what happens with charset.