OneToMany, orphanRemoval=false, target entity is not removed in certain case

Description

We have a OneToMany relationship (List) with cascade ALL and orphanRemoval = false

If we remove a target entity from the List we expect the entity to be removed from the collection but not from the DB.

It works pretty well, when working with a managed parent.

However, if you remove the target entity from the list while the parent is detached and later on you merge the parent, then the target entity is neither removed from the list nor from the database.
See test case attached (you can play with the removeBookWhileAuthorIsDetached flag to make the test pass/fail)

Note that with oprhanRemoval = true, if you remove the target entity from the list while the parent is detached and later on you merge the parent, then the target entity is properly removed from the list and from the database.

Environment

JPA 2.0
Spring 3.2.3.RELEASE
H2 database

Assignee

Unassigned

Reporter

Nicolas Romanetti

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure