Re: [eclipselink-users] enum access cast issue
So you have a List of basic Enum types, stored as String (VARCHAR) in the
database, and in some cases your object's values are the correct Enums, and
in another case (for the same class/attribute) there are Strings in the List
not the Enums, correct?
That is odd, it seems the Converter on the DirectCollectionMapping is not be
utilized in your exception case. What is different about the case where it
works and doesn't? How do you read this object?
> I'm using Glassfish v3 w/EclipseLink and have an entity with a list of
> enums defined as:
> private List<VerbForm> verbForms;
> I can access the verbForms in many cases with no problems, but in one
> particular case where this entity is nested within other entities, when I
> try to reference it, I get a cast error.
> Here is a log from a normal/good case with my debug info showing that it
> is accessed as the correct enum class:
> addAuxVerbs, index: 0|#]
> class com.leadingstep.grammardb.verbs.VerbForm|#]
> cast issues w/addAuxVerbs|#]
> And here is the log when the problem occurs:
> addAuxVerbs, index: 0|#]
> system exception occurred during an invocation on EJB GrammarDBBean method
> public java.util.List
> Caused by: java.lang.ClassCastException: java.lang.String cannot be cast
> to com.leadingstep.grammardb.verbs.VerbForm
> I can include more of the error message if it would be helpful, but I'm
> really at a loss to understand how JPA can access the field and correctly
> interpret it as an Enum class in one instance, but then access the same
> field at the same point in code later and think it is a String that needs
> to be converted? This same entity is embedded indirectly in four other
> different entities and I can access it correctly in three out of four of
> those cases. I can't begin to imagine what could be different in the way
> it's accessed that would cause this problem.
> I had been using the EclipseLink 1.1.2 - Galileo library, but upgraded to
> EclipseLink 2.0.1 and that didn't help or change anything. I'm running on
> a Mac with GlassFish Tools Bundle for Eclipse, v1.2.
> Can anyone give me some clues as to what might be going on and how I can
> resolve this issue?
> Thanks so much,
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
View this message in context: http://old.nabble.com/enum-access-cast-issue-tp28350990p28379839.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.