[ https://issues.apache.org/jira/browse/OPENJPA-1912?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12992405#comment-12992405 ]
Mark Struberg commented on OPENJPA-1912: ---------------------------------------- patch looks fine so far but /org/apache/openjpa/enhance/persistence1.xml is missing. Please see my enhancer.patch for this part. A few notes: 1.) I use //X to comment out 'temporaryily'. This means either a TODO or it needs to be clarified. 2.) The patch assumes that all parent classes must belong to the same persistence unit and therefore also contains the generated writeExternalFields and readExternalFields methods.Is this assumption true, or are there situations where parent.readExternalFields() is invalid? > enhancer generates invalid code if fetch-groups is activated > ------------------------------------------------------------ > > Key: OPENJPA-1912 > URL: https://issues.apache.org/jira/browse/OPENJPA-1912 > Project: OpenJPA > Issue Type: Bug > Components: Enhance > Affects Versions: 2.0.0, 2.0.1, 2.1.0 > Reporter: Mark Struberg > Priority: Critical > Attachments: OPENJPA-1912-enhancer.patch, > OPENJPA-1912-fix-wo_cleanup-2.patch, OPENJPA-1912-fix-wo_cleanup.patch, > OPENJPA-1912-mdd.diff.txt, OPENJPA-1912-test.patch > > > 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); > ... -- This message is automatically generated by JIRA. - For more information on JIRA, see: http://www.atlassian.com/software/jira