Hallo community,
I have a little problem.
I delete a parent-child reltaed entity using EntityManager.delete() and orphanremoval=true in my application.
Code:
@OneToMany(fetch = FetchType.EAGER, mappedBy = "obj_ParentNode",orphanRemoval=true)
private Set<ProjectDataTree> hs_ChildrenNodes = new HashSet<ProjectDataTree>(0);
This works perfect, all entities (including child) are deleted.
After that deleting a formerly-child entity in the same transaction throws an exception, that is correct.
The question is how can I check if an entity is deleted already to avoid throwing an exception? I´m using detach entities.
I tried
Code:
EntityManager.getReference()
EntityManager.getEntityManagerFactory().getPersistenceUnitUtil().isLoaded()
EntityManager.contains()
but nothing works.
Is there something like a list of removed entities?
Can anybody give me a hint to solve my problem?
Thanks in advance!!