这是域类
class Settings {
static constraints = {
uid(nullable: false, unique: true)
data()
}
static hasMany = [items: Item]
Map data
}
class Item{
static constraints = {
name()
email()
approved()
}
static mapping = {
email index: true, indexAttributes: [unique: true]
}
String name
String email
Boolean approved = false;
}
基本上有很多设置对象有很多项目(见下图):
现在我正在查找和更新这样的项目:
...
def item = (Item)Item.findByEmail(email);
if (!item.approved) {
item.approved = true;
item.save(flush: true);
}
...
未保存我在这里缺少什么?