OpenJPA
  1. OpenJPA
  2. OPENJPA-1912

enhancer generates invalid code if fetch-groups is activated

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.0, 2.0.1, 2.1.0
    • Fix Version/s: 2.2.0
    • Component/s: Enhance
    • Labels:
      None

      Description

      If openjpa.DetachState =fetch-groups is used, the enhancer will add a 'implements Externalizable' + writeExternal + readExternal.

      The problem is, that writeExternal and readExternal will also try to externalize the private members of any given superclass. Thus we get a runtime Exception that we are not allowed to access those fields.

      Example:

      @Entity
      public abstract class AbstractGroup

      { ... @Temporal(TemporalType.TIMESTAMP) @TrackChanges private Date applicationBegin; ... }

      and

      @Entity
      public class Group extends AbstractGroup

      { ... }

      will result in the following code (decompiled with jad):

      public void writeExternal(ObjectOutput objectoutput)
      throws IOException
      {
      pcWriteUnmanaged(objectoutput);
      if(pcStateManager != null)

      { if(pcStateManager.writeDetached(objectoutput)) return; }

      else

      { objectoutput.writeObject(pcGetDetachedState()); objectoutput.writeObject(null); }

      objectoutput.writeObject(applicationBegin);
      objectoutput.writeObject(applicationEnd);
      objectoutput.writeObject(applicationLocked);
      objectoutput.writeObject(approvalRequired);
      ...

      1. OPENJPA-1912-test.patch
        11 kB
        Mark Struberg
      2. OPENJPA-1912-mdd.diff.txt
        11 kB
        Michael Dick
      3. OPENJPA-1912-fix-wo_cleanup-2.patch
        16 kB
        Mark Struberg
      4. OPENJPA-1912-fix-wo_cleanup.patch
        5 kB
        Mark Struberg
      5. OPENJPA-1912-enhancer.patch
        2 kB
        Mark Struberg

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Michael Dick
              Reporter:
              Mark Struberg
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development