我有以下表结构:
TABLE A:
ID
COL1
COL2
...
COL(n)
TABLE B:
ID
A_ID (id in table A)
VALUE
存在从 A->B 的一对多关系
class A {
int id
...
coln
Set<String> bSet
static hasMany = [bSet: B]
static mapping = {
restrictions joinTable: [name: "B", key: "A_ID", column: "VALUE"]
}
}
如何构建一个条件,以便它执行如下查询:
select table1.* from A table1 where (select count(*) from B table2 where table2.A_ID = table1.ID and table2.VALUE in ('excluded_value_1','excluded_value_2')) = 0