现在有两张表,文章(Article) 和 目录(Category).
找出某些个目录中的所有文章的hql:
from Article as a left join a.categories as c where c.id in(:ids)
找出某些目录中但不属于指定目录(id=xxx)的hql:
from Article a where a in (select elements(c.articles) from Category c where c.id in (:ids)) and a not in (select elements(c.articles) from Category c where c.id = xxx)
找出某些个目录中的所有文章的hql:
from Article as a left join a.categories as c where c.id in(:ids)
找出某些目录中但不属于指定目录(id=xxx)的hql:
from Article a where a in (select elements(c.articles) from Category c where c.id in (:ids)) and a not in (select elements(c.articles) from Category c where c.id = xxx)