code: @Override
      public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
          Object o = context.getEntity();
          if (o != null && isWritable(o.getClass())) {
  
              MultivaluedMap<String, String> queryParams = uriInfoProvider.get().getQueryParameters();
              SpiQuery query = null;
              if (o instanceof Finder) {
                  query = (SpiQuery) ((Finder) o).query();
              } else if (o instanceof Query) {
                  query = (SpiQuery) o;
              } else if (o instanceof ExpressionList) {
                  query = (SpiQuery) ((ExpressionList) o).query();
              } else if (o instanceof FutureList) {
                  query = (SpiQuery) ((FutureList) o).getQuery();
              } else if (o instanceof FutureIds) {
                  query = (SpiQuery) ((FutureIds) o).getQuery();
              }
  
              if (query != null) {
                  FutureRowCount rowCount = applyUriQuery(queryParams, query, manager);
                  Object result;
                  if (o instanceof FutureList) {
                      result = ((FutureList) o).getUnchecked();
                  } else if (o instanceof FutureIds) {
                      try {
                          result = ((FutureIds) o).get();
                      } catch (InterruptedException e) {
                          Thread.currentThread().interrupt();
                          throw new PersistenceException(e);
  
                      } catch (ExecutionException e) {
                          throw new PersistenceException(e);
                      }
                  } else {
                      result = query.findList();
                  }
  
                  applyRowCountHeader(context.getHeaders(), query, rowCount);
  
                  context.setEntity(result);
  
                  if (result != null)
                      context.setType(result.getClass());
  
                  context.setGenericType(query.getBeanType());
              }
          } else if (o instanceof BeanCollection && !BeanCollection.class.isAssignableFrom(context.getType())) {
              context.setEntity(o.getClass());
          }
  
          context.proceed();
      }
docs: {@inheritDoc}