Re: java.lang.ClassCastException: com.webobjects.eocontrol.EOGenericRecord cannot be cast to com.cariatides.noyau.modele.noyauppersonne.Personne
Re: java.lang.ClassCastException: com.webobjects.eocontrol.EOGenericRecord cannot be cast to com.cariatides.noyau.modele.noyauppersonne.Personne
- Subject: Re: java.lang.ClassCastException: com.webobjects.eocontrol.EOGenericRecord cannot be cast to com.cariatides.noyau.modele.noyauppersonne.Personne
- From: Pascal Robert <email@hidden>
- Date: Wed, 18 Apr 2012 10:32:28 -0400
Bonjour G. Alexandre,
I guess that you are getting the exception in the rechercherParNip method? And are you using Project Wonder? If yes, you can reduce the amount of code by using the Wonder methods and make your code more solid. If you are not using Wonder, you should.
> hi,
> When i execute my test methods with java, i have :
> java.lang.ClassCastException: com.webobjects.eocontrol.EOGenericRecord cannot be cast to com.cariatides.noyau.modele.noyauppersonne.Personne
> But my class personne extends EOCustomObject so i don't know why i have this error. When i inspect listeResultat.objectAtIndex(0), i have a person but i don't cast it.
>
> public void test() {
> NSArray entryList;
> ERXExtensions.initApp(your.app.Application.class, new String[0]);
> EOEditingContext editingContext = new EOEditingContext();
> entryList = EOUtilities.rawRowsForSQL(editingContext, "MaTable", "select count(*) from MaTable", null);
> Personne p = Personne.rechercherParNip(editingContext, 9793l);
> System.out.println(p);
> System.out.println(entryList);
> }
>
>
> public static Personne rechercherParNip(EOEditingContext editingContexte, Long critereNip, boolean refetch) {
> EOKeyValueQualifier qualifieur = null;
> EOFetchSpecification specification = null;
> NSArray listeResultat = null;
> Personne resultat = null;
>
> try {
> qualifieur = new EOKeyValueQualifier("nip", EOQualifier.QualifierOperatorEqual, critereNip);
> specification = new EOFetchSpecification("Personne", qualifieur, null);
> //specification.setRefreshesRefetchedObjects(refetch);
> listeResultat = editingContexte.objectsWithFetchSpecification(specification);
> if ((null != listeResultat) && (1 == listeResultat.count())) {
> resultat = (Patient) listeResultat.objectAtIndex(0);
> }
> } catch (Exception exception) {
> System.out.println("Personne.rechercherParNip(....) : ");
> System.out.println(exception.toString());
> resultat = null;
> }
> return resultat;
> }
>
>
> Best regards G.ALEXANDRE
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden