Here are the domain classes
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;
}
Basically there are many Settings objects that have many items (see illustration below):
Now I'm finding and updating an item like so:
...
def item = (Item)Item.findByEmail(email);
if (!item.approved) {
item.approved = true;
item.save(flush: true);
}
...
Not Saved what am I missing here?