考虑下面的对象结构。
Product
id : int
name : string
attribute : list of Attribute
Attribute
id : int
name: string
value : string
product_id : int
这些问题是:用QueryOver如何形成一个子查询返回所有产品符合下列条件:
选择其中具有在同一时间属性时,所有的产品:
属性名= “COLOR” VALUE = “红”,属性名= “大小” 值= “XXL”?
编辑: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)