Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: 1.0.1
-
Fix Version/s: 1.0.2
-
Component/s: Persistence
-
Labels:None
-
Environment:JDK 1.6, Vista
-
Testcase included:yes
Description
Test case below. Each is zipped in attachment. Running a Grails app with the files and pointing the browser at http://localhost:8080/test/foo/testChanges
will show the following list:
- second bar of first foo
- first bar of first foo
Refreshing the view will continue to show this same list, when it should reverse each time. The println's verify this phenomena. No assertion errors are shown to exist. This demonstrates the view gets a cached version of the reversed Foo.bars list, but doesn't persist the change properly.
class Foo {
String name
List bars
static hasMany = [bars : Bar]
static mapping = {
columns {
bars(lazy: false)
}
}
}
class Bar {
String name
Foo foo
}
====== in Bootstrap=======
Foo foo = new Foo(name: 'first foo')
foo.addToBars(new Bar(name: 'first bar of first foo'))
foo.addToBars(new Bar(name: 'second bar of first foo'))
foo.save()
====== in FooController=======
def testChanges = {
println '======'
def firstFoo = Foo.get(1)
firstFoo.bars.each {println it.name}
println ''
def bar = firstFoo.bars[0]
firstFoo.bars[0] = firstFoo.bars[1]
firstFoo.bars[1] = bar
firstFoo.bars.each {println it.name}
assert firstFoo.save()
println '======'
}
====== testChanges.gsp=======<html>
<head>
<title>Testing serializing list changes</title>
</head>
<body>
<% def firstFoo = Foo.get(1) %>
<h1>${firstFoo.name}</h1>
<ul>
<g:each var="bar" in="${firstFoo.bars}">
<li>${bar.name}</li>
</g:each>
</ul>
</body>
</html>
I'm in contact with guys on the Hibernate team about this one, but this process is taking time, hence rolling to next release