I used SQL Profiler to capture the generated statement:
Code:
select
items1_.item_id as item_id,
items1_.swatch_id as swatch_id,
items1_.location as location,
items1_.open_qty as open_qty,
items1_.reserved_qty as reserved5_,
items1_.available_qty as availabl6_,
items1_.purpose as purpose,
items1_.expiry_date as expiry_d8_,
items1_.CreateBy as CreateBy,
items1_.CreateDate as CreateDate,
items1_.LastUpdateBy as LastUpd11_,
items1_.LastUpdateDate as LastUpd12_,
items1_.item_id as item_id__,
items1_.swatch_id as swatch_id__,
COUNT(inv_swat0_.swatch_id) as x0_0_
from inv_swatches inv_swat0_
inner join inv_item items1_
on inv_swat0_.swatch_id=items1_.swatch_id
I dont understand, the SELECT clause in HQL statement I wrote is:
Code:
SELECT COUNT(sw.SwatchID) FROM warehouse.to.inv_swatches AS sw INNER JOIN FETCH sw.Items AS invitem
I also tried:
Code:
SELECT COUNT(sw) FROM warehouse.to.inv_swatches AS sw INNER JOIN FETCH sw.Items AS invitem
And...
Code:
SELECT COUNT(*) FROM warehouse.to.inv_swatches AS sw INNER JOIN FETCH sw.Items AS invitem
None of which
does not include field/column "item_id"! Running this statement manually results in:
Quote:
Column 'items1_.item_id' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.
Thanks in advance!