I'm working in grails 2.3.8
We have the following domain classes:
abstract class GroupItem {
static belongsTo = [group:AppGroup]
static mapping = {
tablePerHierarchy = false
}
}
class MyDomain extends GroupItem {
String name
String type
int Identifier
static hasMany = [attributes:Attribute]
static mapping = {
attributes cascade: 'all-delete-orphan'
}
}
class Attribute {
String name
String value
static belongsTo = [myDomain:MyDomain]
}
In my controller's 'update' method I am trying to update a 'MyDomain' object. I can update the attributes that associate with the domain fine, however when I try and change any of the properties on an instance itself (name, identifier or type) the changes don't persist. The controller code:
def update(Long id) {
---
def myDomain = MyDomain.get(id)
myDomain.type = 'DIFFERENT TYPE'
myDomain.save(flush:true, failOnError:true)
}
However the signal in the database still has the same type as when it was created. To try and follow the logic I added a beforeUpdate method to the domain class that prints out the type and I can see that it is getting called and in beforeUpdate it thinks the type is my new value, however the update is never persisted. There are no exceptions, the objects validate, and nothing in any logs. Any clue what could be causing this?
Cheers!