I've create https://issues.apache.org/jira/browse/OPENJPA-2177 and attached a small maven/junit test case demonstrating the issue.
Thanks, Mike On 4/25/12 12:22 PM, "Rick Curtis" <[email protected]> wrote: >> Should a JIRA ticket be created for this. >Yes, please do. Thanks for taking the time to come up with a small UT. > >Thanks, >Rick > >On Wed, Apr 25, 2012 at 11:00 AM, Mike Goldner ><[email protected]>wrote: > >> Rick, >> >> OK, so in the process of trying to create a stand-alone reproducible >>test >> of this problem I have figured out the issue. >> >> I was not including my @MappedSuperclass entity in the persistence.xml >>as >> a managed entity. This seems to interfere/corrupt the internal OpenJPA >> field indexing. >> >> While it was an error on my part to omit the @MappedSuperclass from the >> persistence.xml, it is somewhat confusing because the documentation >> stresses that the class annotated with @MappedSuperClass is *not* an >> entity. >> >> Also, the way in which the error manifests is extremely subtle and >> confusing. I'm assuming that the enhancer is responsible for this. I'd >> expect is to behave differently in this situation. >> >> Should a JIRA ticket be created for this. >> >> I do have a pretty simple maven project with a reproducible test for >>this >> issue if you are interested. >> >> Thanks, >> >> Mike >> >> On 4/25/12 9:50 AM, "Rick Curtis" <[email protected]> wrote: >> >> >Mike - >> > >> >Can you post the Entities that you're having problems with? >> > >> >Thanks, >> >Rick >> > >> >On Tue, Apr 24, 2012 at 10:47 PM, Mike Goldner >> ><[email protected]>wrote: >> > >> >> I have an entity that extends an abstract MappedSuperClass class. >>The >> >> abstract class only declares an ID and Version field. >> >> >> >> When I attempt to persist the object, I get the following error: >> >> >> >> 2185 [main] DEBUG openjpa.Runtime - An exception occurred while >>ending >> >>the >> >> transaction. This exception will be re-thrown. >> >> java.lang.ClassCastException: java.util.ArrayList cannot be cast to >> >> java.lang.String >> >> at >> >> >> >> >> >>>>org.apache.openjpa.kernel.TransferFieldManager.fetchStringField(Transfe >>>>rF >> >>iel >> >> dManager.java:76) >> >> >> >> I'm not familiar with the OpenJPA codebase, but I made an attempt to >>see >> >> what was happening via the Eclipse debugger. >> >> >> >> It seems that while in the StateManagerImpl class there is a >>mismatch in >> >> field numbering used to retrieve fields from my entity. In my case, >>I >> >>am >> >> expecting to fetch a String value for my field. While in the >> >> "fetchString(int field)" method, I have a field number that >>corresponds >> >>to >> >> the field index of the _meta._allFields array. However, when the >>code >> >> proceeds to the "fetchStringField(int field)" method, it seems to >> >>return a >> >> completely different field (an ArrayList, which explains the >>exception). >> >> >> >> While it may be coincidence, I notice that there is a _pc field that >> >> appears >> >> to have a representation of my entity fields that is sorted >> >>alphabetically >> >> and does not match the ordering of the _meta._allFields field. >> >> >> >> I am running OpenJPA 2.2.0 with Java 6 using Derby as the DB. I am >> >> enhancing the classes at compile time using the openjpa-maven-plugin. >> >> >> >> Mike Goldner >> >> >> >> >> >> >> > >> > >> >-- >> >*Rick Curtis* >> >> >> > > >-- >*Rick Curtis*
