I execute this my code and i don't understant why elapsed time is very high for loop.
There are two loops. First loop on Invoices table and the seconde loop on InvoicesLignes table.
InvoicesLignes table has a index "Code", it's the "foreign-key" of Invoice. In database Access, there is a relation between Invoices and InvoicesLines, but the foreign-key is not defined and i can't use the Joiner class. I can't modify Database.
import java.io.File;
import java.util.Date;
import java.io.IOException;
import com.healthmarketscience.jackcess.*;
class MultipleLoop {
  public static void main(String[] args) {
    File jfile = new File("/project/database.mdb");
    Date start_date= new Date("2013/01/01");
    Date end_date= new Date("2013/12/31");
    try {
        Database db = DatabaseBuilder.open(jfile);
        Table invoices = db.getTable("Invoices");
        Table invoices_lignes = db.getTable("InvoiceLignes");
        Cursor cursor = CursorBuilder.createCursor(invoices_lignes.getIndex("Code"));
        for(Row invoice : invoices) {
          if ((start_date.before((Date)invoice.get("Date")) 
                    || start_date.equals((Date)invoice.get("Date"))) 
              &&  
              (end_date.after((Date)invoice.get("Date")) 
                    || end_date.equals((Date)invoice.get("Date")) )) {
          System.out.println(String.format("Invoice id : '%s' time : '%s'", 
                             invoice.get("Code"),
                             System.currentTimeMillis( ) ));
          long start = System.currentTimeMillis( );
          for (Row invoice_ligne : cursor.newIterable().addMatchPattern("Code",
                                                           invoice.get("Code"))) 
          {
              System.out.println(String.format("Loop time : '%s'", 
                                 System.currentTimeMillis( )));
          }
          long end = System.currentTimeMillis( );
          System.out.println(String.format("\n\nEnd loop time : '%s'", 
                             System.currentTimeMillis( )));
          long diff = end - start;
          System.out.println(String.format("Loop elapsed time : '%s' ms\n\n", 
                             diff ));
          }
        }
       } catch (IOException e) {
      //} catch (Exception e) {
        System.out.println(e);
      }
    }
}
and my log is
Invoice id : '19901/79018' time : '1411043140236' 
Loop time : '1411043140237'
Loop time : '1411043140237'
Loop time : '1411043140237'
Loop time : '1411043140237'
End loop time : '1411043141335'
Loop elapsed time : '1098' ms
 Invoice id : '138901/909719' time : '1411043141335'
 Loop time : '1411043141336'
 Loop time : '1411043141336'
 End loop time : '1411043142418'
 Loop elapsed time : '1083' ms
 Invoice id : '1309091/729090' time : '1411043142419'
 Loop time : '1411043142419'
 Loop time : '1411043142419'
 End loop time : '1411043143515'
 Loop elapsed time : '1096' ms
I don't understand why elapsed time is very high for loop
Thank for your help
 
     
    