cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pascal Robert <prob...@druide.com>
Subject Re: Best method to fetch a lot of objects
Date Wed, 24 May 2017 13:42:09 GMT

> Le 24 mai 2017 à 03:34, Andrus Adamchik <andrus@objectstyle.org> a écrit :
> 
> 
>> On May 23, 2017, at 3:02 PM, Pascal Robert <probert@druide.com> 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.
Mime
View raw message