Do you want the BulkEmails to remain after you have deleted the Template? I'm not sure it's particularly common, but you can do it by adding a nullable: true constraint to BulkEmail:
Code:
class BulkEmail {
Template template
static constraints = {
template nullable: true
}
}
Before you delete the template, you have to nullify all references to it:
Code:
def template = Template.get(templateId)
BulkEmail.findAllByTemplate(template).each { it.template = null }
template.delete()
You could also add a hasMany in Template and use the removeFrom() method instead. It's up to you.