Grails

Cascading does not work in a one to many association on a self referencing class with belongsTo set

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 1.0
  • Fix Version/s: 1.0.2
  • Component/s: Persistence
  • Labels:
    None

Description

This is my domain class:

class Category
 {
     String name
     Set items
     Category parentCategory
     Set subCategories

     static hasMany = [subCategories: Category, items: Item]
     static belongsTo = [parentCategory: Category]

     static constraints =
     {
         parentCategory(nullable: true)
         name(nullable: true)
      }

}

I'd like when I delete a category, that the children are deleted, not the parents (which seems fairly natural with this belongsTo). However the contrary happens. If I remove the belongsTo, then there is no cascade at all which is still not the behaviour I want.
I guess this bug happens because both end of the relationship belong to the same class.

Activity

Hide
Graeme Rocher added a comment -

Bulk closing bunch of resolved issues

Show
Graeme Rocher added a comment - Bulk closing bunch of resolved issues

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: