views:

5

answers:

0

I would like to create a one-to-many association that does not cascade deletes. Reading the Grails Reference it says

The default cascading behaviour is to cascade saves and updates, but not deletes unless a belongsTo is also specified

That isn't the behavior I'm seeing. With the following class implementations I get cascaded updates, saves, and deletes without any belongsTo:

class A {
   static hasMany = [bees: B]
}
class B { }

In one Hibernate session I do the following to verify cascade updates work:

def a = new A()
a.save()
def b1 = new B()
a.addToBees(b1)
def b2 = new B()
a.addToBees(b2)

Then, in another Hibernate session, the following code deletes all instances of A and B:

A.list().each { a -> a.delete() }

Is this a bug? Is the documentation wrong? Am I doing something incorrectly? I'm using the Grails console to verify this behavior.