PART 1
Following up solutions to Querying Mongo Collection using QueryBuilder in Mongo 3.3.0 , I tried implementing the suggested methods to im
The second argument of find method is result type. Try as below.
FindIterable tDocTypeList = dbCollection.find(filter, TDocType.class);
Update for projection
FindIterable tDocTypeList = dbCollection.find(filter, TDocType.class).projection(outputQuery);
Update for appending filters
List filters = new ArrayList<>();
for (Map.Entry entry : query.getParams().entrySet()) {
// this is where its building the query
if (some condition){
filters.add(Filters.eq(entry.getKey(), entry.getValue()));
}
if (some other condition){
filters.add(Filters.in(entry.getKey(), query.getValues()));
}
}
FindIterable docType = dbCollection.find(Filters.and(filters));