Consider the following object structure.
Product
id : int
name : string
attribute : list of Attribute
Attribute
id : int
name: string
value : string
product_id : int
The questions is: Using QueryOver how to form a subquery to return all products with the following conditions:
Select all products where when have attributes at the same time:
Attribute name = "Color" Value="Red" and Attribute name = "Size" Value="XXL" ?
Edit: Sample sql:
select * from Product p where
exists (select id from attribute where name = 'Color' and value = 'Red' and product_id = p.id)
and
exists (select id from attribute where name = 'Size' and value = 'XXL' and product_id = p.id)