Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top