I have 3 entities:
Code:
public class Item
{
public Long id;
}
public class Contract
{
public Long id;
public Collection<ContractItem> items;
}
public class ContractItem
{
public Long id;
public Contract contract;
public Item item;
public BigDecimal price;
}
I want to query all items and their prices in specified contracts. How can I do it in HQL? In SQL it's solving by simple query:
Code:
SELECT i.id, ci1.price, ci2.price, ...
FROM Items i
LEFT JOIN ContractItem ci1 ON ci1.item = i.id
LEFT JOIN ContractItem ci2 ON ci2.item = i.id
...
WHERE ci1.contract = ? AND ci2.contract = ? AND ...