We're updating the issue view to help you get more done. 

Session.merge() and Session.update() behave differently for cascade="all-delete-orphan" relationships

Description

I have the following entity relationship setup.

class Parent {
inverse="true" cascade="all-delete-orphan" (hbm)
Set<Child> children;
}
class Child {
(many-to-one)
Parent parent;

inverse="true" cascade="all-delete-orphan" (hbm)
Set<GrandChild> grandChildren;
}
class GrandChild {
(many-to-one)
Child child;

String name;
}

Our application load's the parent class instance and sends it to the UI in one transaction and does one of the following below before calling saveOrUpdate() in a different transaction.

>When updating a grand child's name and calling Session.saveOrUpdate(Parent) the child's name is updated due to cascade
>When adding a new grand child in the Child's set and calling
Session.saveOrUpdate(Patent) the new child is added due to cascade
>But When removing grand child element from the child and then doing a
Session.saveOrUpdate(Parent) doesn't remove the child in fact the version column of the that grandchild record is untouched,
Session.update(Parent) also doesn't remove the grand child.

but doing Session.merge(Parent) does remove the grand child

Is this correct behavior? I thought if "all-delete-orphan" option is given then it should cascade regardless of it being a merge() or update().

I am using Spring Framework's HibernateTemplate.merge(), HibernateTemplate.update(), HibernateTemplate.saveOrUpdate() functions.
My database server is MSSQL 2008

Environment

Hibernate 4.2.12 with Spring Framework 4.0.3

Status

Assignee

Unassigned

Reporter

M

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

4.2.12

Priority

Major