code: private Map<String, List<DBObject>> onPersist(Map<String, List<DBObject>> collections, Object entity, Object id,
              EntityMetadata metadata, List<RelationHolder> relationHolders, boolean isUpdate)
      {
          persistenceUnit = metadata.getPersistenceUnit();
          Map<String, DBObject> documents = handler.getDocumentFromEntity(metadata, entity, relationHolders,
                  kunderaMetadata);
  
          if (isUpdate)
          {
              for (String documentName : documents.keySet())
              {
                  BasicDBObject query = new BasicDBObject();
  
                  MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                          metadata.getPersistenceUnit());
  
                  if (metaModel.isEmbeddable(metadata.getIdAttribute().getBindableJavaType()))
                  {
                      MongoDBUtils.populateCompoundKey(query, metadata, metaModel, id);
                  }
                  else
                  {
                      query.put("_id", MongoDBUtils.populateValue(id, id.getClass()));
                  }
                  DBCollection dbCollection = mongoDb.getCollection(documentName);
                  KunderaCoreUtils.printQuery("Persist collection:" + documentName, showQuery);
  
                  dbCollection.save(documents.get(documentName), getWriteConcern());
              }
          }
          else
          {
              for (String documentName : documents.keySet())
              {
                  // a db collection can have multiple records..
                  // and we can have a collection of records as well.
                  List<DBObject> dbStatements = null;
                  if (collections.containsKey(documentName))
                  {
                      dbStatements = collections.get(documentName);
                      dbStatements.add(documents.get(documentName));
                  }
                  else
                  {
                      dbStatements = new ArrayList<DBObject>();
                      dbStatements.add(documents.get(documentName));
                      collections.put(documentName, dbStatements);
                  }
              }
          }
          return collections;
      }
docs: Executes on list of entities to be persisted.
  
  @param collections
  collection containing list of db objects.
  @param entity
  entity in question.
  @param id
  entity id.
  @param metadata
  entity metadata
  @param relationHolders
  relation holders.
  @param isUpdate
  if it is an update
  @return collection of DB objects.