现在有两个对象 Product , AttrItem ,多对多的关系, 在Product中有一个AttrItem的set,我现在想写一个HQL语句查询Product,查询条件是Product中的AttrItem属性包含某特定AttrItem集合,而且Product的price属性还要在给定的范围内。我写的查询语句是:
from Product as p where (from AttrItem where id in ('31','32')) in elements(p.attrItems) and (price >= 0 and price <= 6)
上面31,32是AttrItem的id,上面的HQL无法执行,估计 in elements 只能判断单行记录是否在某个集合中,无法判断多行记录是否在某集合中。那这段HQL应该怎样写呢
------解决思路----------------------
换成exist试试