> Le 24 mai 2017 à 03:34, Andrus Adamchik <[email protected]> a écrit :
>
>
>> On May 23, 2017, at 3:02 PM, Pascal Robert <[email protected]> wrote:
>>
>>>
>>> Do all your MySQL entities contain an ObjAttribute for their PK?
>>
>> In fact, the source is FileMaker, and even if the field is listed as a
>> number with autofill, that stupid database still allows NULL or non-number
>> values...
>
> So maybe null PKs are the culprit? Can you check for null, and assign a PK
> yourself?
This is what I do, but not only the PK is null, but the fetched object is null.
try(ResultIterator<ContactsPrincipaux> contactsPrincipaux =
ObjectSelect.query(ContactsPrincipaux.class).iterator(context)) {
try(BufferedWriter writer = Files.newBufferedWriter(file.toPath(),
charset, StandardOpenOption.CREATE)) {
for (ContactsPrincipaux contact: contactsPrincipaux) {
if (contact != null && contact.getKpCodeContact() != null) {
String s = contact.getKpCodeContact() + ";" +
contact.getInfoPrenom() + ";" + contact.getInfoNom() + ";" +
contact.getInfoCourriel1() + ";" + contact.getAdressePrincipaleCodepostal() +
"\n";
writer.write(s, 0, s.length());
} else {
System.out.println(contact);
}
}
} catch (IOException ex) {
}
}
When the FileMaker record does not have a value in kp_code_contact, contact is
null.