-
Notifications
You must be signed in to change notification settings - Fork 199
Description
Original Reporter: mathpere
Environment: Ubuntu 10, Open JDK, Grails 1.3.7, mongo 1.0.0.M7
Version: 1.0.0.M7
Migrated From: http://jira.grails.org/browse/GPMONGODB-334
{code:title=Bar.groovy|borderStyle=solid}
class Bar {
ObjectId id
String foo
List<String> strings = new ArrayList()
}
{code}
If I only modify my "strings" property, the save() is not performed. This applies as well to embedded collections, I have not checked with Map properties
It seems like GORM checks for changes in the domain object, and does not detect changes in lists
{code:title=BarController.groovy|borderStyle=solid}
class BarController {
def test={
Bar bar = new Bar(foo:'foo')
bar.strings.add("test")
bar.save()
//bar is correctly saved
bar = Bar.get(bar.id)
bar.strings.add("test2")
bar.save()
//for some reason this works too, and the new value is added to the strings
session.bar = bar.id
}
def doesNotWork={
def bar = Bar.get(session.bar)
bar.strings.add("hello")
bar.save()
println bar.strings
//in the bean, the strings are correctly modified, but nothing is saved in the db
}
def doesWork={
def bar = Bar.find(session.bar)
bar.strings.add("hello")
bar.foo += " "
bar.save()
// When we modify another property of bar, the object is saved
// It seems like GORM checks for changes in the domain object, and does not detect changes in lists
// This can be reproduced with embedded collections too
// I also had similar issues with boolean
}
}
{code}