I've the below sql query and I need corresponding hql.
Code:
select * from cost_pool c left outer join sub_cost_pool s on c.cost_pool_code=s.cost_pool_code and s.model_id=1 where c.cost_pool_code='BD-100'
Cost pool has a collection(sub_cost_pool) as a property. I need to filter the collection based on model_id
It should return one object with a filtered collection
I tried this
Code:
from CostPool c left join c.subCostPools sc with sc.model.modelId=:modelId where c.costPoolCode=:costPoolCode
It didn't work...it was returning a list of 2 objects (1 costpool with unfiltered collection, 1 subcostpool).
Please help me. I already spent couple of hours on this. I tried using filters, it didn't help me.