Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 1.1-RC1
-
Fix Version/s: 1.1.1
-
Component/s: Persistence
-
Labels:None
Description
I encoutered some problems with my parent-child domain classes when deleting childs.
I couldn't actually pinpoint why and when in was going wrong but after adding and deleteing childs suddenly records were not deleted.
This problems occured using the controllers and views.
I tried to reproduce it in Bootstrap by adding and deleting stuff and veryfing my actions. But it al seemed to work according to my println's...
However it's not the case!
Run the attached application.
- In Bootstrap an invoice is created with some child lines
- Then in bootstrap I remove, add and again remove some lines
- At the end it has just 1 line as is also displayed using a println
- So everything seems to be fine.....
- But in the started application go the edit view of the invoice and it will display 3 lines (should be just 1 line)
-
Hide
- parentchild-bug-report-26022009.zip
- 25/Feb/09 5:13 PM
- 26 kB
- Marcel Overdijk
-
- grails-app/conf/BootStrap.groovy 3 kB
- grails-app/conf/Config.groovy 3 kB
- grails-app/conf/DataSource.groovy 0.6 kB
- grails-app/conf/UrlMappings.groovy 0.2 kB
- grails-app/conf/spring/resources.groovy 0.0 kB
- grails-app/.../CustomerController.groovy 3 kB
- grails-app/.../SalesInvoiceController.groovy 5 kB
- grails-app/domain/Customer.groovy 0.2 kB
- grails-app/domain/SalesInvoice.groovy 0.5 kB
- grails-app/.../SalesInvoiceLine.groovy 0.5 kB
- grails-app/i18n/messages.properties 3 kB
- grails-app/i18n/messages_de.properties 3 kB
- grails-app/i18n/messages_es.properties 3 kB
- grails-app/i18n/messages_fr.properties 2 kB
- grails-app/i18n/messages_it.properties 2 kB
- grails-app/i18n/messages_ja.properties 2 kB
- grails-app/i18n/messages_nl.properties 3 kB
- grails-app/.../messages_pt_BR.properties 3 kB
- grails-app/i18n/messages_ru.properties 4 kB
- grails-app/i18n/messages_th.properties 5 kB
- grails-app/.../messages_zh_CN.properties 2 kB
- grails-app/views/customer/create.gsp 2 kB
- grails-app/views/customer/edit.gsp 3 kB
- grails-app/views/customer/list.gsp 2 kB
- grails-app/views/customer/show.gsp 3 kB
- grails-app/views/error.gsp 2 kB
- grails-app/views/index.gsp 0.9 kB
- grails-app/views/layouts/main.gsp 0.7 kB
- grails-app/views/salesInvoice/_line.gsp 0.8 kB
- grails-app/views/salesInvoice/_lines.gsp 1 kB
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
I thought that was needed. Just as I don't explicitly call save() on the child.
Maybe we should put that somewhere in the docs?
I also tried a custom mapping in SalesInvoice like:
static mapping = { lines cascade: "all,delete-orphan" }
But it makes no difference.
The ref guide (5.5.2.9 Custom Cascade Behaviour) states that this would delete removed childs automatically.
Seems it is supposed to be "all-delete-orphan" I have corrected the docs
FYI - the "all,delete-orphan" error still exists in the 1.1 docs. http://www.grails.org/doc/1.1/
I ran into problems today after removing a child from a parent, I was getting a null property exception at the end of the transaction , as in child.parent cannot be null. I think it makes sense to delete the child automatically if it has one parent and it is removed from that parent, but maybe I am not seeing the bigger picture...
You're not explicilty calling delete() on the child, just calling removeFrom* doesn't delete the instance