Dirk, I had a similar problem, and the solution (I may not have used the API correctly) was intense. Eclipselink maintains an object cache, and if they are not updated (merged / saved), the database reflects the change, but cascading objects are not updated (especially parents).
(I declared A as an entry connecting several B) Objects:
public class A { @OneToMany(cascade = CascadeType.ALL) Collection b; } public class B { @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.REFRESH})
In the above case, the workaround is:
public void saveB(B b)
What you do here physically cascades the chain fusion from above. This is annoying, but it solves the problem. Alternatively, you can handle this by checking to see if it disconnects and is updated / replaced, but I found this to be less desirable and annoying.
If anyone has a better answer regarding the right setup, I would be glad to hear it. I have now used this approach for my relational entities, and this is definitely annoying.
Good luck with this, I would like to hear a better solution.
source share