@Override public <T> List<T> findBySpatialView(SpatialViewQuery query, Class<T> entityClass) { //we'll always need to get documents, as a RawJsonDocument, so we should force includeDocs(false) //so that the caller doesn't set a bad target class unintentionally, pre-loading with a bad type. query.includeDocs(false); try { final SpatialViewResult response = querySpatialView(query); if (response.error() != null) { throw new CouchbaseQueryExecutionException("Unable to execute spatial view query due to the following view error: " + response.error().toString()); } List<SpatialViewRow> allRows = response.allRows(); final List<T> result = new ArrayList<T>(allRows.size()); for (final SpatialViewRow row : allRows) { //cope with potential weak consistency and deletions T entity = mapToEntity(row.id(), row.document(RawJsonDocument.class), entityClass); if (entity != null) { result.add(entity); } } return result; } catch (TranscodingException e) { throw new CouchbaseQueryExecutionException("Unable to execute view query", e); } }
@Override public <T> List<T> findBySpatialView(SpatialViewQuery query, Class<T> entityClass) { //we'll always need to get documents, as a RawJsonDocument, so we should force includeDocs(false) //so that the caller doesn't set a bad target class unintentionally, pre-loading with a bad type. query.includeDocs(false); try { final SpatialViewResult response = querySpatialView(query); if (response.error() != null) { throw new CouchbaseQueryExecutionException("Unable to execute spatial view query due to the following view error: " + response.error().toString()); } List<SpatialViewRow> allRows = response.allRows(); final List<T> result = new ArrayList<T>(allRows.size()); for (final SpatialViewRow row : allRows) { //cope with potential weak consistency and deletions T entity = mapToEntity(row.id(), row.document(RawJsonDocument.class), entityClass); if (entity != null) { result.add(entity); } } return result; } catch (TranscodingException e) { throw new CouchbaseQueryExecutionException("Unable to execute view query", e); } }