假设我们有一个类Person,它包含Set<Book> books。
要找到所有拥有“有效Java”一书的人,您可以这样写:
select p from Person p left outer join fetch p.books as b where b.name='Effective Java'现在,我如何才能打开这个查询的头,并找到所有的Person 没有这本书?
select p from Person p "where p.books does not contain book b where b.name='Effective Java'"发布于 2019-02-01 13:33:54
您可以利用NOT EXISTS关键字:
select p
from Person p
where not exists (
select b from p.books b where b.name = 'Effective Java'
)发布于 2019-02-01 13:39:15
或者说
select p from Person p join p.books b where b.name <> 'Effective Java'https://stackoverflow.com/questions/54480168
复制相似问题