Question

I have EntityA and EntityB. EntityA has a to-many relationship with EntityB.

I have several EntityB objects that have been set as related (children) to EntityA. How can I delete that relationship without deleting any of the Entity objects?

Was it helpful?

Solution

Try the following:

EntityB entityB = myEntityBDao.load(id_entityB);
entityB.setEntityA(null);
entityB.update();

This just deletes the relation and modifies entityB, but a formerly related EntityA should not be deleted or even modified.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top