0 Replies Latest reply on Feb 23, 2006 2:52 PM by Dave Chen

    After merge, property changed

    Dave Chen Master

      Two entities, Picture and Person, ManyToOne

      Class Picture {

      public Person getOwner() {... }


      Picture picture = <a detached entity>
      // the picture has a owner that is an instance of Person(not CGLIB enhanced).
      //change picture name, then merge
      Picture p = em.merge(picture);

      The owner(Person) of p is changed to a CGLIB enhanced instance, and its all member variables become null. It has an Initializer that says initialized=true.

      Why is that? I expected the object returned from em.merge() would keep all the data.

      One thing I do not understand:

      em.create(entity) will change entity directly. For merge, why it return a different instance? which instance should I work on after merge?

      Thanks for help.