I have a problem with updating related entities.
Let me start with a straightforward example. Suppose I have a User 1:1 Profile relation.
How can I update (replace) Profile entity which belongs to User ?
I have tried the followings without success (both OneToOne relation has CascadeType=ALL property)
em.getTransaction().begin();
1.User.setProfile(Profile)
....
2.User.setProfile(Profile)
Profile.setUser(User)
.....
3.em.remove(User.getProfile())
User.setProfile(Profile)
Profile.setUser(User)
em.getTransaction().commit();
I'm totally confused with JPA, there are some useful example, but they are not about updating entities (just updating single values, raising salary etc ...)
I hope the suggested way will work on in case of 1:N relations as well.