0

我有三个表 A、B 和 A_B(带有 @ManyToMany 注释)。

我尝试使用以下查询请求所有没有特定 b.id (:k) 的 A 对象:“Select disctinct a from A a join aB b where b.id != :k”

但我也想要所有没有现有 b.id 的 A 对象,并且上面的这个查询只返回没有 b.id 的 A 对象。

我能怎么做?我需要在 b.id 上使用“不存在”吗?

PS:对不起我的英语,它不是我的母语。

4

1 回答 1

2
select a from A a where :k not member of a.bs

(k 参数应该是 B 的实例,其 ID 为要拒绝)

于 2012-05-18T20:38:08.707 回答