private QuerySqlContext createQueryContext(
     OrcsSession session, QueryData queryData, QueryType queryType) throws OseeCoreException {
   QuerySqlContext context = new QuerySqlContext(session, queryData.getOptions(), type);
   AbstractSqlWriter writer =
       new QuerySqlWriter(logger, joinFactory, sqlProvider, context, queryType, table, idColumn);
   List<SqlHandler<?>> handlers = handlerFactory.createHandlers(queryData.getCriteriaSets());
   writer.build(handlers);
   return context;
 }
 private void writeQuery(QueryData queryData) throws IOException {
   List<CriteriaSet> criteriaSets = queryData.getCriteriaSets();
   List<SelectSet> selectSets = queryData.getSelectSets();
   writer.writeArrayFieldStart("query");
   for (int index = 0; index < criteriaSets.size(); index++) {
     writer.writeStartObject();
     writer.writeNumberField("level", index);
     writeCriterias(criteriaSets.get(index));
     writeCollect(selectSets.get(index));
     writer.writeEndObject();
   }
   writer.writeEndArray();
 }