Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2540

merge without DetachedStateField deletes lazy fields in embedded entities

    Details

    • Type: Bug
    • Status: Open
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: 2.3.0
    • Fix Version/s: None
    • Component/s: kernel
    • Labels:
      None

      Description

      I am using the setting <property name="openjpa.DetachState" value="fetch-groups(DetachedStateField=false)" />

      Like the summary says, I have an embedded entity with a field that is lazily fetched. This is a field that is persisted whenever the entity is persisted. (It doesn't matter whether it is a @Basic field or a @ManyToOne relation with cascade = CascadeType.ALL). When I merge a detached entity that has null for such a field, the field is actually made null in the database. The expected behavior is for OpenJPA to notice that the field is not in the fetch plan and ignore it on merge.

      The problem only exists when using an embedded entity together with the DetachedStateField=false setting.

      I created a test case which shows the issue. It is based on that of OPENJPA-1983 which reported a similar issue but whose test case didn't use an embedded entity.

        Attachments

        1. Inner.java
          0.6 kB
          Vermeulen
        2. Lazy.java
          0.5 kB
          Vermeulen
        3. LazyFieldsInEmbeddedEntityTest.java
          3 kB
          Vermeulen
        4. TestEmbeddable.java
          1.0 kB
          Vermeulen

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                slowstrider Vermeulen
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: