[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] problem with remove on bidirectional oneToMany entities
|
Hello Yannick,
father.getSonsCollection().remove(son); is equivalent to
List<Son> sons = father.getSonsCollection();
sons.remove(son);
father.setSonsCollection(sons);
so entityManager.merge(father) will be required in either case if
father is detached. Try em.contains(father) before the merge to see if
it is managed or not. If father is a managed entity, the change to the
sons collection should be picked up without the merge call.
Best Regards,
Chris
Yannick Majoros wrote:
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
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users