Hi Alex,

Thanks a lot., you have right.
In fact, I defined the pk of the view on field which contain the same code for 
all data. 
So I redefined my pk on another field which have unique code for each data and 
it works.


So I go to write fetch spec to clear my fetching data.


Thanks
========================================

Message du : 09/06/2011
De : "Alexis Tual " <alexis.t...@gmail.com>
A : naneon.raym...@neuf.fr
Copie à : webobjects-dev@lists.apple.com
Sujet : Re: Duplicated data after fetching on a view


 Hi Naneon,


my guess is that your entities mapping your views have no primary key defined 
(i'm not sure it's even allowed)... or the primary key defined is not one (not 
unique)


Cheers


Alex



Le 9 juin 2011 à 11:00, naneon.raym...@neuf.fr a écrit :
Hi All,


I create a view to get all data I want and do a fetch on WO to return specific 
data. So When I create my fetching code, the sqlExpression is good but return 
same data several times although it count different data.
I.e : 


Java fetch code:  NSMutableArray<EOQualifier> qualFinal = new 
NSMutableArray<EOQualifier>();
                NSMutableArray<String> qualFi = new NSMutableArray<String>();
                qualFi.add("110");
                qualFi.add("120");
                NSArray DiplOrderings = new NSArray(new Object[]{
                                
EOSortOrdering.sortOrderingWithKey(DilplomeSpec.DIPL_SPEC_C_KEY,EOSortOrdering.CompareAscending),
                                
EOSortOrdering.sortOrderingWithKey(DilplomeSpec.DIPLOME_C_KEY,EOSortOrdering.CompareAscending)});
                EOQualifier qualING2 = EOQualifier.qualifierWithQualifierFormat(
                                "diplomeC = %@", new NSArray<String>("ING2"));
                EOQualifier qualING2a = 
EOQualifier.qualifierWithQualifierFormat(
                                "diplSpecC <> %@ AND diplSpecC <> %@", new 
NSArray<String>(qualFi));
                qualFinal.add(qualING2);
                qualFinal.add(qualING2a);
                EOQualifier ingenieux = new EOAndQualifier(qualFinal);
                EOQualifier qualMST = EOQualifier.qualifierWithQualifierFormat(
                                "diplomeC = %@", new NSArray<String>("MST"));
                //Liste des spécialité Ingénieur
                
sessionFr.setIngenieurs(DilplomeSpec.fetchDilplomeSpecs(session().defaultEditingContext(),
 ingenieux, DiplOrderings));
                for (int i=0; i <sessionFr.getIngenieurs().count(); i++){
                        DilplomeSpec ing = 
sessionFr.getIngenieurs().objectAtIndex(i);
                        NSLog.out.appendln(ing.descFr());
                }
                //Liste des spécialités master
                
sessionFr.setMasters(DilplomeSpec.fetchDilplomeSpecs(session().defaultEditingContext(),
 qualMST, DiplOrderings));
                for (int i=0; i <sessionFr.getMasters().count(); i++){
                        DilplomeSpec mst = 
sessionFr.getMasters().objectAtIndex(i);
                        NSLog.out.appendln(mst.descFr());
                }


Result in Log : 


2327 [WorkerThread0] DEBUG NSLog  -  evaluateExpression: 
<com.webobjects.jdbcadaptor.OraclePlugIn$OracleExpression: "SELECT t0.DESC_EN, 
t0.DESC_FR, t0.DIPL_SPEC_C, t0.DIPLOME_C FROM GERRY.V_DIPSPEC_PRDDEF t0 WHERE 
(t0.DIPLOME_C = ? AND (t0.DIPL_SPEC_C <> ? AND t0.DIPL_SPEC_C <> ?)) ORDER BY 
t0.DIPL_SPEC_C ASC, t0.DIPLOME_C ASC" withBindings: 1:"ING2"(diplomeC), 
2:"110"(diplSpecC), 3:"120"(diplSpecC)>
2460 [WorkerThread0] DEBUG NSLog  - 6 row(s) processed
2461 [WorkerThread0] DEBUG NSLog  -  === Commit Internal Transaction
2480 [WorkerThread0] INFO NSLog  - Systèmes d'Information et de 
Télécommunications (SIT)
2480 [WorkerThread0] INFO NSLog  - Systèmes d'Information et de 
Télécommunications (SIT)
2480 [WorkerThread0] INFO NSLog  - Systèmes d'Information et de 
Télécommunications (SIT)
2480 [WorkerThread0] INFO NSLog  - Systèmes d'Information et de 
Télécommunications (SIT)
2480 [WorkerThread0] INFO NSLog  - Systèmes d'Information et de 
Télécommunications (SIT)
2480 [WorkerThread0] INFO NSLog  - Systèmes d'Information et de 
Télécommunications (SIT)
2480 [WorkerThread0] DEBUG NSLog  -  === Begin Internal Transaction
2480 [WorkerThread0] DEBUG NSLog  -  evaluateExpression: 
<com.webobjects.jdbcadaptor.OraclePlugIn$OracleExpression: "SELECT t0.DESC_EN, 
t0.DESC_FR, t0.DIPL_SPEC_C, t0.DIPLOME_C FROM GERRY.V_DIPSPEC_PRDDEF t0 WHERE 
t0.DIPLOME_C = ? ORDER BY t0.DIPL_SPEC_C ASC, t0.DIPLOME_C ASC" withBindings: 
1:"MST"(diplomeC)>
2485 [WorkerThread0] DEBUG NSLog  - 4 row(s) processed
2486 [WorkerThread0] DEBUG NSLog  -  === Commit Internal Transaction
2486 [WorkerThread0] INFO NSLog  - Convention Master (CV MAST)
2486 [WorkerThread0] INFO NSLog  - Convention Master (CV MAST)
2486 [WorkerThread0] INFO NSLog  - Convention Master (CV MAST)
2486 [WorkerThread0] INFO NSLog  - Convention Master (CV MAST)


When I excecute this SQL Expression in SqlDeveloper I have this result :


Expression 1 : SELECT t0.DESC_EN, t0.DESC_FR, t0.DIPL_SPEC_C, t0.DIPLOME_C FROM 
GERRY.V_DIPSPEC_PRDDEF t0 WHERE (t0.DIPLOME_C = 'ING2' AND (t0.DIPL_SPEC_C <> 
'110' AND t0.DIPL_SPEC_C <> '120')) ORDER BY t0.DIPL_SPEC_C ASC, t0.DIPLOME_C 
ASC;


Result : 

"DESC_EN"                                                                       
                   "DESC_FR"                                                   
"DIPL_SPEC_C"    "DIPLOME_C"
1-"Information Systems and telecommunications (SIT)"    "Systmes d'Information 
et de TŽlŽcommunications (SIT)" "121"   "ING2"
2-"Industrial Systems (SI)"     "Systmes Industriels (SI)"     "122"   "ING2"
3-"Mechanical Systems (SM)"     "Systmes MŽcaniques (SM)"      "123"   "ING2"
4-"Materials Science and Technology (MTE)"      "MatŽriaux : Technologie et 
Economie (MTE)"     "124"   "ING2"
5-"Informatique et Systmes d'Information (ISI)"        "Informatique et 
Systmes d'Information (ISI)"  "125"   "ING2"
6-"Systmes, RŽseaux et TŽlŽcommunications (SRT)"       "Systmes, RŽseaux et 
TŽlŽcommunications (SRT)" "126"   "ING2"


Expression 2 : SELECT t0.DESC_EN, t0.DESC_FR, t0.DIPL_SPEC_C, t0.DIPLOME_C FROM 
GERRY.V_DIPSPEC_PRDDEF t0 WHERE t0.DIPLOME_C = 'MST' ORDER BY t0.DIPL_SPEC_C 
ASC, t0.DIPLOME_C ASC;



"DESC_EN"                                                               
"DESC_FR"               "DIPL_SPEC_C"   "DIPLOME_C"
1-"Convention Master (CV MAST)" "Convention Master (CV MAST)"   "70"    "MST"
2-"MŽcanique et Physique (MP)"  "MŽcanique et Physique (MP)"    "781"   "MST"
3-"Sciences et Technologies de l'information et de la communication (STIC)"     
"Sciences et Technologies de l'information et de la communication (STIC)"       
"782"   "MST"
4-"IngŽnierie et management (IM)"       "IngŽnierie et management (IM)" "783"   
"MST"




My Question is Why WO return the same data and How to fix it?


Thanks for all _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/alexis.tual%40gmail.com

This email sent to alexis.t...@gmail.com


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to