Hello!
My problem is:
I want to remove an entity, what have a @ManyToOne relation and for this relation I configured cascade=CascadeType.REMOVE.
When I trying to remove:
Code:
entityManager.remove(entityManager.merge(entity));
I get this error message: java.lang.IllegalArgumentException: Removing a detached instance relatedEntity.
When I configure the relation other side with @OneToMany(cascade=CascadeType.REMOVE), and trying to remove the related entity.
Code:
entityManager.remove(entityManager.merge(relatedEntity))
Everithing is OK.
Why is this behaviour?