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