openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From José Luis Cetina <>
Subject Insert new record + update child object
Date Mon, 08 Apr 2013 16:44:48 GMT
Hi. I have a problem with insert and updating a reference in the same

Im trying to insert a new object (Exam) that has a reference to another
object (Person) and at the same time i want to update an attribute
(birthDate) of the Person object. The update never happens although i
set CascadeType to ALL.  The only way this works is doing a persist and
after that a merge operation.  Is this normal? Do i have to change

I dont like the idea of a "manual update" using merge in the Person object
because i don't know how many objects (child object of Exam) the user want
to update.


public class Exam{
   @ManyToOne(cascade= CascadeType.ALL)
   @JoinColumn(name = "person_id")
   public Person person;

public class Person{
    private Date birthDate;
   @OneToMany(mappedBy = "person")
    private List<Exam> exams

public class SomeClass{
   public void someMethod(){
      exam = new Exam()
      person.setBirthDate(new Date());

public class someEJB(){

   public void saveExam(Exam exam){
        //THIS WORKS


Do i have to use the MERGE method for every child object?

Here is the same question from other user:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message