Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Duplicate
-
Affects Version/s: 1.0-RC1
-
Fix Version/s: 1.0.2
-
Component/s: Persistence
-
Labels:None
-
Environment:java 6 grails 1.0RC1
Description
1-Many relationship
delete relation will cause error
null in List
I write a test
tow class and a script file
class Book {
String name
List pages
static hasMany = [pages : Page]
}
class Page {
Book book
static belongsTo = Book
String name
}
(1..3).each{i->
bn="book"+i
if( !(Book.findWhere(name:bn)))
new Book(name:bn).save()
}
b=Book.get(1)
(1..3).each{i->
pn="page"+i
p=new Page(name:pn)
b.addToPages(p).save()
p.save()
}
(1..3).each{i->
pn= "page"+i
p= Page.findWhere(name : pn)
b.removeFromPages(p)
p.delete()
p=new Page(name:pn)
b.addToPages(p).save()
p.save()
}
b.pages.each{
if(it) println it.name
else println "null"
}
run serveral times, output is:
null
null
null
null
null
null
page1
page2
page3
page1
page3
page1
page2
page3
page1
page2
page3
page1
page2
page3
in my app( database is mysql)
the problem is more serious
Message: null index column for collection: CertClass.certStudents
Hi, I have the same problem. When using a List, the items are not always removed. I've added a project which displays the error:
Steps to reproduce:
Go to ProductBacklog.groovy, uncomment the List backlogItems
Go the the http://localhost:8080/XProject/project/show/1 page. Add a few items (around 10 wil do), and remove them (starting somewhere in the middle). What will happen is that items will remain in the productBacklog?.backlogItems list, but when doing a BacklogItems.list(), the items are removed, so there's a difference.
Note this doesn't happen when using a Set (the default behaviour)