Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
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?



drrevis wrote:
> 
> Hi,
> 
> I'm using Glassfish v3 w/EclipseLink and have an entity with a list of
> enums defined as:
> 
> @ElementCollection
> 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:
> 
> [#|2010-04-23T15:08:21.113-0400|INFO|glassfishv3.0|com.leadingstep.grammardb.sentences|_ThreadID=27;_ThreadName=Thread-1;|calling
> addAuxVerbs, index: 0|#]
> 
> [#|2010-04-23T15:08:21.113-0400|INFO|glassfishv3.0|com.leadingstep.grammardb.sentences|_ThreadID=27;_ThreadName=Thread-1;|verbForm:
> ED|#]
> 
> [#|2010-04-23T15:08:21.113-0400|INFO|glassfishv3.0|com.leadingstep.grammardb.sentences|_ThreadID=27;_ThreadName=Thread-1;|class:
> class com.leadingstep.grammardb.verbs.VerbForm|#]
> 
> [#|2010-04-23T15:08:21.113-0400|INFO|glassfishv3.0|com.leadingstep.grammardb.sentences|_ThreadID=27;_ThreadName=Thread-1;|no
> cast issues w/addAuxVerbs|#]
> 
> -----------------
> 
> And here is the log when the problem occurs:
> 
> [#|2010-04-23T15:09:23.582-0400|INFO|glassfishv3.0|com.leadingstep.grammardb.sentences|_ThreadID=26;_ThreadName=Thread-1;|calling
> addAuxVerbs, index: 0|#]
> 
> [#|2010-04-23T15:09:23.582-0400|INFO|glassfishv3.0|com.leadingstep.grammardb.sentences|_ThreadID=26;_ThreadName=Thread-1;|verbForm:
> ED|#]
> 
> [#|2010-04-23T15:09:23.582-0400|WARNING|glassfishv3.0|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=26;_ThreadName=Thread-1;|A
> system exception occurred during an invocation on EJB GrammarDBBean method
> public java.util.List
> com.leadingstep.grammardb.beans.GrammarDBBean.fetchAllModifiedNounValues(com.leadingstep.grammardb.nouns.ModifiedNoun)
> javax.ejb.EJBException
> at
> com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5070)
> 
> <snip>
> 
> Caused by: java.lang.ClassCastException: java.lang.String cannot be cast
> to com.leadingstep.grammardb.verbs.VerbForm
> at
> com.leadingstep.grammardb.sentences.Predicate.fetchValue(Predicate.java:1047)
> 
> -------------------
> 
> 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,
> Renee
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
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.



Back to the top