Description
I would like to resurrect a previously reported bug...
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.
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?
- GORM Version: 6.1.12
- Grails Version (if using Grails): 3.3.14
- JDK Version: 1.8
Example Application
There is an example app here #11321