在数据库中我有两个表 模板 和 报告 Template 和 Report ;
Template
Report
class Template { static hasMany = [reports: Report] ... }
class Report { static belongsTo = [template: Template] ... }
违约行为似乎是 模板 如果删除,则删除将被级联,以便 它也将被删除。 模板id -中的列 报告 -表be a 外键,但没用。
模板
有什么方法可以覆盖级联删除吗?
应在 Template 班级:
static mapping = { reports cascade: 'none' }
模板 没有问题,除了 Report 上课也是必要的:
static constraints = { template(nullable: true) }