You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"isDirty() does not currently check collection associations, but it does check all other persistent properties and associations."
But the documentation doesn't tell you how to make these associations save, since apparently it can't detect changes automatically.
Person person = Person.findByName('alber2')
Position position = Position.findByName('boss2')
person.addToPositions(position)
This does not save the new relationship.
In the 1:M case, lack of auto dirty checking doesn't seem such a problem because one of the visible tables will have changed and will be dirty. But in the M:M case, the table that needs to change is the invisible table position_person that's automatically populated.
One can't call markDirty() on the intervening position_person table, because it's invisible to the programmer in the infrastructure.
I've tried marking the owning table and subordinate tables as dirty:
Person person = Person.findByName('alber2')
Position position = Position.findByName('boss2)
person.addToPositions(position)
position.markDirty()
person.markDirty()
But that doesn't work. person.isDirty() still returns false, and the relationship doesn't save.
How is this supposed to work? How can I get the relationship to save?
I would like to resurrect a previously reported bug...
grails/grails-core#11321
Because I for one can't see how there is not some kind of bug here.
According to the documentation http://gorm.grails.org/6.0.x/hibernate/manual/#modificationChecking
"isDirty() does not currently check collection associations, but it does check all other persistent properties and associations."
But the documentation doesn't tell you how to make these associations save, since apparently it can't detect changes automatically.
This does not save the new relationship.
In the 1:M case, lack of auto dirty checking doesn't seem such a problem because one of the visible tables will have changed and will be dirty. But in the M:M case, the table that needs to change is the invisible table position_person that's automatically populated.
One can't call markDirty() on the intervening position_person table, because it's invisible to the programmer in the infrastructure.
I've tried marking the owning table and subordinate tables as dirty:
Person person = Person.findByName('alber2')
Position position = Position.findByName('boss2)
person.addToPositions(position)
position.markDirty()
person.markDirty()
But that doesn't work. person.isDirty() still returns false, and the relationship doesn't save.
How is this supposed to work? How can I get the relationship to save?
Example Application
There is an example app here grails/grails-core#11321
The text was updated successfully, but these errors were encountered: