我在几个不同的位置看到过这种行为,可以说:
class fruits {
static hasMany=[preapples:Apples, apples: Apples, postapples: Apples ]
}
static mapping = {
preapples cascade: 'lock'
apples cascade: 'lock'
postapples cascade: 'lock'
}
static constraints = {
preapples nullable:true
apples nullable:true
postapples nullable:true
}
如果在水果上生成视图,我会选择许多苹果apple1 apple2等
如果我现在返回并从apple1 + apple2更改为apple1 - 一切正常
如果我取消选择全部,如果只有1个被选中,我选择ctrl来取消它 - 它清楚地显示没有选择任何内容 - 当我提交表单时,实际上并没有删除该值。
这与可空的有关吗?或者我错过了一些明显的东西
我已经按照建议添加了nullable true,这与选择值然后取消选择没有区别。
我还修改了实际的sql表结构(命名为苹果和水果但是在进行更改/删除表之前以及在重新创建表之后进行更改 - 没有区别可空(已经可以为空)
mysql> describe fruits_apples;
+-----------------------------------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------------------+------------+------+-----+---------+-------+
| fruits_apples_id | bigint(20) | YES | MUL | NULL | |
| apples_id | bigint(20) | YES | MUL | NULL | |
| fruits_postapples_id | bigint(20) | YES | MUL | NULL | |
| fruits_preapples_id | bigint(20) | YES | MUL | NULL | |
|
mysql> describe fruits_shell_scripts;
+-----------------------------------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------------------+------------+------+-----+---------+-------+
| fruits_apples_id | bigint(20) | YES | MUL | NULL | |
| apples_id | bigint(20) | YES | MUL | NULL | |
| fruits_postapples_id | bigint(20) | YES | MUL | NULL | |
| fruits_preapples_id | bigint(20) | YES | MUL | NULL | |
+-----------------------------------+------------+------+-----+---------+-------+
此致