Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top