javax.persistence.EntityManager.remove in some cases does not remove object

Description

Problematic situation is when we have two entities in one to many relation (Task and Note in this case). The "parent" of the relation has to be annotated with cascade PERSIST and the returned type has to be a map. When the element of that map is retrieved and passed to the entity manager remove method, the removal does not take place.

Please see attached files. They should explain everything. If you have any question send it to:
arkadiusz.firus@gmail.com

Environment

None

Activity

Show:
Arkadiusz Firus
March 13, 2015, 9:11 PM

I can not find a way to edit description so I write it as a comment. I hope it is not a problem.

Problematic situation is when we have two entities in one to many relation (Task and Note in this case). The "parent" of the relation has to be annotated with cascade PERSIST and the returned type has to be a map. When the element of that map is retrieved and passed to the entity manager remove method, the removal does not take place.

I really apologize for not adding description. In my opinion example/test case is more descriptive than my poor English.

If you have any more question/suggestions feel free to ask.

Gail Badner
March 14, 2015, 12:09 AM

I've updated the description.

Your English is very good!

Gail Badner
March 14, 2015, 12:34 AM

This is expected behavior. The "removed" entity was not removed from the Map. On flush, the persist operation will be cascaded to the "removed" entity, and will be made "managed".

Arkadiusz Firus
March 14, 2015, 7:34 AM

I have read the JPA 2.1 specification one more time and you are right. Sorry for inconvenience.

Gail Badner
March 16, 2015, 5:43 PM

Confirmed by author.

Assignee

Gail Badner

Reporter

Arkadiusz Firus

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure