Hope this helps The solution is to remove the reference to EntityA from the EntityB (first). In this case Doctrine will try to persist an EntityB without. But if we combine this with orphanRemoval=true, we'll get the aimed result:
help you fix your problem Cascading the removal will make Hibernate call entityManager.remove() on the referenced entity (or collection of entities). The referenced entity will thus be removed from the database. But it leaves the entity instances untouched. Note that having a cascade=REMOVE (or ALL) on a ManyToOne is usually a very bad idea. You generally don't want to remove a user when removing just one of its memberships.
EntityManager.remove() does not generate delete query and does not remove entity
I hope this helps . I figured out what caused the problem. I had form fields in the order detail that were disabled. These disabled fields were not sent to the server by my browser. This causes doctrine to remove those children. There has been some discussion on this issue here. In order to still have field that cannot be changed, but are still visible I removed the disabled attribute and added the attribute readonly => true to those form fields and my problem is resolved.
Java 8 Map of Collections remove element from collection and remove entry if empty