【发布时间】:2012-11-03 21:46:33
【问题描述】:
我在 mygrails 项目中有 2 个类,名为 Profile 和 License 以下是课程中重要内容的大纲
class Profile {
Set<Licence> licenceKeys
static hasMany = [licenceKeys:Licence]
static constraints = {
licenceKeys nullable:true
}
static mapping = {
licenceKeys cascade: 'all-delete-orphan'
}
}
class Licence {
Profile profile
String licenceKey
static belongsTo = [profile:Profile]
static constraints = {
profile nullable:false
licenceKey blank:true, nullable:true, unique:true
}
}
当我在我的一个控制器中运行以下代码时
if (!profile.licenceKeys.clear()) {
log.error ("Error occured removing licence keys from the database");
userProfile.errors.each { err -> println err; }
} else {
log.info("Successfully remove licence keys from the database");
}
我在控制台中收到以下错误消息,并且许可证密钥保留在数据库中 org.springframework.validation.BeanPropertyBindingResult: 0 个错误 密钥已从 Profile 类中设置的 licenceKeys 中删除,但仍保留在数据库中
我有 2 个问题 是否有可能为我收到的错误消息获得更好的调试输出 我是否遗漏了确保从数据库中删除 licekey 的任何内容?
谢谢
【问题讨论】:
标签: grails grails-orm