Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] problem with remove on bidirectional oneToMany entities

Hi,

We have two entity classes, Father and Son

We are in an EJB environment, transactions are managed automatically.

When a son is removed, we used to do this:

father.getSonsCollection().remove(son);
entityManager.remove(son);

It seems that the cache gets corrupted if we don't do this after those two lines:

entityManager.merge(father);

Is this right? I would think it isn't, "father" should be automatically updated (in cache, thus).

Or should I write this:

List<Son> sons = father.getSonsCollection();
sons.remove(son);
father.setSonsCollection(sons);

without entityManager.merge(fatcher)

Thanks,

Yannick Majoros


Back to the top