code: @Nullable
      private Object getSingleResult(Query query) {
          if (projection != null) {
              Object result = query.getSingleResult();
              if (result != null) {
                  if (!result.getClass().isArray()) {
                      result = new Object[]{result};
                  }
                  return projection.newInstance((Object[]) result);
              } else {
                  return null;
              }
          } else {
              return query.getSingleResult();
          }
      }
docs: Transforms results using FactoryExpression if ResultTransformer can't be used
  
  @param query query
  @return single result