public void flush() {
    databaseMapping.lemmaMapping.insertObjects(
        connection, "lemmata", databaseMapping.lemmaMap.keySet());
    databaseMapping.wordformMapping.insertObjects(
        connection, "wordforms", databaseMapping.wordformMap.keySet());

    for (Object o : databaseMapping.awfMap.keySet()) {
      NEAnalyzedWordform awf = (NEAnalyzedWordform) o;
      awf.lemmaKey = awf.lemma.primaryKey;
      awf.wordformKey = awf.wordform.primaryKey;
    }

    databaseMapping.awfMapping.insertObjects(
        connection, "analyzed_wordforms", databaseMapping.awfMap.keySet());

    for (Object o : databaseMapping.containmentMap.keySet()) {
      NEContainment nec = (NEContainment) o;
      nec.parentKey = nec.parent.primaryKey;
      nec.childKey = nec.child.primaryKey;
    }

    if (databaseMapping.containmentMap.size() > 0)
      databaseMapping.containmentMapping.insertObjects(
          connection, "analyzed_wordform_groups", databaseMapping.containmentMap.keySet());

    for (Object o : databaseMapping.attestationMap.keySet()) {
      NEAttestation at = (NEAttestation) o;
      at.documentKey = at.document.primaryKey;
      at.analyzedWordformKey = at.awf.primaryKey;
    }
    databaseMapping.attestationMapping.insertObjectsInPortions(
        connection, "token_attestations", databaseMapping.attestationMap.keySet(), 10000);
  }
 private NEAnalyzedWordform createNEAnalyzedWordform(NELemma neLemma, NEWordform neWord) {
   NEAnalyzedWordform awf = new NEAnalyzedWordform();
   awf.lemma = neLemma;
   awf.wordform = neWord;
   awf = (NEAnalyzedWordform) DatabaseMapping.canonical(databaseMapping.awfMap, awf);
   return awf;
 }