code: public List executeQuery(Statement stmt, EntityMetadata em)
      {
          N1qlQuery query = N1qlQuery.simple(stmt, N1qlParams.build().consistency(ScanConsistency.REQUEST_PLUS));
          N1qlQueryResult list = bucket.query(query);
          LOGGER.debug("Executed query : " + query.toString() + " on the " + bucket.name() + " Bucket");
          validateQueryResults(stmt.toString(), list);
  
          List records = new ArrayList<>();
          for (N1qlQueryRow row : list)
          {
              MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata()
                      .getMetamodel(em.getPersistenceUnit());
              EntityType entityType = metaModel.entity(em.getEntityClazz());
  
              JsonObject jsonObj = row.value().containsKey(em.getSchema()) ? row.value().getObject(em.getSchema())
                      : row.value();
  
              records.add(handler.getEntityFromDocument(em.getEntityClazz(), jsonObj, entityType));
          }
  
          return records;
  
      }
docs: Execute query.
  
  @param stmt
  the statement
  @param em
  the entity manager
  @return the list