openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Goldner <mike.gold...@gmail.com>
Subject FieldMapping for entity incorrect, wrong field read from object
Date Wed, 25 Apr 2012 03:47:04 GMT
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(TransferFiel
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



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message