diff --git a/src/main/java/org/springframework/datastore/document/mongodb/MongoTemplate.java b/src/main/java/org/springframework/datastore/document/mongodb/MongoTemplate.java index 3a4eb1d00..e11552343 100644 --- a/src/main/java/org/springframework/datastore/document/mongodb/MongoTemplate.java +++ b/src/main/java/org/springframework/datastore/document/mongodb/MongoTemplate.java @@ -25,10 +25,8 @@ import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.datastore.document.AbstractDocumentStoreTemplate; import org.springframework.datastore.document.DocumentMapper; import org.springframework.datastore.document.DocumentSource; -import org.springframework.datastore.document.InvalidDocumentStoreApiUageException; -import org.springframework.util.Assert; +import org.springframework.datastore.document.mongodb.query.Query; -import com.mongodb.BasicDBObject; import com.mongodb.CommandResult; import com.mongodb.DB; import com.mongodb.DBCollection; @@ -109,21 +107,12 @@ public class MongoTemplate extends AbstractDocumentStoreTemplate { return results; } - public List queryForList(String collectionName, String fieldName, String[] operands, Object[] values, Class targetClass) { + public List queryForList(String collectionName, Query query, Class targetClass) { DocumentMapper mapper = MongoBeanPropertyDocumentMapper.newInstance(targetClass); - return queryForList(collectionName, fieldName, operands, values, mapper); + return queryForList(collectionName, query, mapper); } - public List queryForList(String collectionName, String fieldName, String[] operands, Object[] values, DocumentMapper mapper) { - if (operands.length != values.length) { - throw new InvalidDocumentStoreApiUageException("The number of operands and values must match"); - } - DBObject query = new BasicDBObject(); - DBObject condition = new BasicDBObject(); - for (int i = 0; i < operands.length; i++) { - condition.put(operands[i], values[i]); - } - query.put(fieldName, condition); + public List queryForList(String collectionName, Query query, DocumentMapper mapper) { return queryForList(collectionName, query, mapper); }