[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] enum access cast issue
|
Hi James,
I keep hitting this problem in slightly different ways as I'm trying to use
the code and really need to figure out a way around it. I know I should be
able to store a list of enums like this with JPA 2.0 so it seems like this
may be a bug. Do you think I should just give up for now, store it as a
list of strings and convert to a list of enums on the fly using a transient
field? Any other suggestions?
Renee
drrevis wrote:
>
> Hi James,
>
> The code where it works and where it fails is exactly the same. The
> offending line (with associated logging) is from the predicate object:
>
> logger.info("calling addAuxVerbs, index: " + verbFormIndex);
> logger.info("verbForm: " + verbForms.get(verbFormIndex));
> logger.info("class: " + verbForms.get(verbFormIndex).getClass());
> addAuxVerbs(sentence, sentencePredicate,
> verbForms.get(verbFormIndex));
> logger.info("no cast issues w/addAuxVerbs");
>
>
> And here is a portion of the predicate object definition:
>
> public class Predicate implements Serializable {
>
> @Id
> @GeneratedValue(strategy = GenerationType.TABLE, generator =
> "predicateIDGen")
> private Long itemID;
> private String name;
> @ManyToOne
> private SentenceGroup sentenceGroup;
> private PredicatePattern pattern = PredicatePattern.CLAUSE_VI;
> @OneToOne
> private Verb verb1;
> @OneToOne
> private Verb verb2;
> @ElementCollection
> @Enumerated(EnumType.ORDINAL)
> private List<VerbForm> verbForms;
>
> etc. ......
>
>
>
>
> The logs that are generated in the successful case are:
>
> -------------------
> [#|2010-05-04T11:28:13.463-0400|INFO|glassfishv3.0|com.leadingstep.grammardb.sentences|_ThreadID=35;_ThreadName=Thread-1;|calling
> addAuxVerbs, index: 0|#]
>
> [#|2010-05-04T11:28:13.466-0400|INFO|glassfishv3.0|com.leadingstep.grammardb.sentences|_ThreadID=35;_ThreadName=Thread-1;|verbForm:
> ED|#]
>
> [#|2010-05-04T11:28:13.466-0400|INFO|glassfishv3.0|com.leadingstep.grammardb.sentences|_ThreadID=35;_ThreadName=Thread-1;|class:
> class com.leadingstep.grammardb.verbs.VerbForm|#]
>
> [#|2010-05-04T11:28:13.466-0400|INFO|glassfishv3.0|com.leadingstep.grammardb.sentences|_ThreadID=35;_ThreadName=Thread-1;|no
> cast issues w/addAuxVerbs|#]
> -------------------
>
>
> Then in the failed case, the logs are:
>
> -------------------
>
> [#|2010-05-04T11:31:03.626-0400|INFO|glassfishv3.0|com.leadingstep.grammardb.sentences|_ThreadID=35;_ThreadName=Thread-1;|calling
> addAuxVerbs, index: 0|#]
>
> [#|2010-05-04T11:31:03.626-0400|INFO|glassfishv3.0|com.leadingstep.grammardb.sentences|_ThreadID=35;_ThreadName=Thread-1;|verbForm:
> ED|#]
>
> [#|2010-05-04T11:31:03.626-0400|WARNING|glassfishv3.0|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=35;_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:1061)
>
> -------------------
>
>
> The particular predicate object that I'm accessing is the same in both the
> successful and failed cases and the verbForms list is not updated between
> the two accesses. The logs show that the index it is using is the same in
> both cases and the value of the particular verbForm is the same, but when
> I try to access the class, I get the error. (Note that when the logging
> stmt is removed, I get this same error at the addAuxVerbs line).
>
>
> I know that the system initially sees the verbForm list as being a list of
> VerbForm enums from this log:
>
> [#|2010-05-04T11:19:56.388-0400|CONFIG|glassfishv3.0|org.eclipse.persistence.session.file:/Users/renee/Documents/workspace_LeadingStep/.metadata/.plugins/com.sun.enterprise.jst.server.sunappsrv92/domain1/eclipseApps/LS_Mgmt_App/GrammarElement_EJB_jar/_GrammarElement_EJB.ejb_or_metadata|_ThreadID=26;_ThreadName=Thread-1;|The
> target class (reference) class for the element collection mapping element
> [field verbForms] is being defaulted to: class
> com.leadingstep.grammardb.verbs.VerbForm.|#]
>
>
> I hope this is enough info to demonstrate the problem. I'm happy to do
> whatever else I can to narrow down the underlying issue, but I just don't
> know what else to look at.
>
> Renee
>
>
>
> James Sutherland wrote:
>>
>> I don't seem to be able to see you attachments. Perhaps inline them, or
>> provide a link.
>>
>> Also include the code for the classes where it works, and where it does
>> not.
>>
>>
>
>
--
View this message in context: http://old.nabble.com/enum-access-cast-issue-tp28350990p28475879.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.