I use Grails and am pretty surprised at how relationships work hasMany. I have a typical relationship hasManywhere the parent id is in the child table. When I insert a child and try to save it through the parent, the version identifier of the parent is incremented. My question is: why change the parent version identifier when there is a change only in the child?
class Parent {
static hasMany = [children: child]
}
class child {
string name
Parent parent
static belongsTo = [Parent]
}
def p = Parent.get(1)
p.addToChildren(new Child(name: "Roy"))
p.save()
The version pincreases from 0 to 1. Is there a way to avoid this in Grails?
Due to a change in the identifier of the parent version, I get an outdated object exception. Any help?