Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

merge() updates/add children but doesn't update the parent

686901Feb 23 2009 — edited Feb 25 2009
Hello all,

I am using Toplink/JPA in my application and have had great success with it previously. The problem I am running into here seems quite odd. I have an annotated pojo similar to the following as the parent class:
public class ParentClass {

     @Column(name = "multiple")
     protected int multiple = 1;

     @Column(name = "description")
     protected String description;

     @OneToMany(cascade = CascadeType.ALL, mappedBy = "myParent")
     protected List<Child> answers = new ArrayList<Child>();

    /*
     * necessary getters and setters below
     */

     ...
}
and an other as the child class:
public class Child {

     @ManyToOne(cascade = CascadeType.ALL)
     @JoinColumn(name = "entry_id")
     private ScorecardEntry myEntry;
}
The problem is that when I change the parent class by changing multiple and/or description as well as add new (unmanaged/unpersisted) Child objects to the collection and do a em.merge(parent); all of the children are being persisted but the parent objects fields are not. I sure I am doing something wrong and that is the cause but I can't seem to figure out what it is. Any information that can be provided is greatly appreciated in advance.

Thanks,
Justen L. Britain
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 25 2009
Added on Feb 23 2009
1 comment
587 views