i have a similar issue as the guy from this post:
JPA cascade persist and references to detached entities throws PersistentObjectException. Why?
(only that i have ManyToMany instead of OneToOne) and i solved it by either:
1. removing Cascade
2. using merge instead of persist
but (there is always a 'but'), if i choose the nr 2, after this operation has completed and if i look in the database everything is ok, when i perform
Bar bar = em.find(Bar.class,barId);
List<Foo> foos = bar.getFoos();
i get the Bar entity without the the new Foo objects added by merge operation.
I specify that if i remove Cascade and use em.persist() everything works as expected.
Any sugestions ?