Example usage for com.mongodb QueryOperators IN

List of usage examples for com.mongodb QueryOperators IN

Introduction

In this page you can find the example usage for com.mongodb QueryOperators IN.

Prototype

String IN

To view the source code for com.mongodb QueryOperators IN.

Click Source Link

Usage

From source file:org.sculptor.framework.accessimpl.mongodb.MongoDbChunkFetcher.java

License:Apache License

@Override
protected List<T> getChunk(Collection<KEY> keys) {
    DBObject query = new BasicDBObject();
    DBObject inCondition = new BasicDBObject();
    Collection<KEY> restrictionPropertyValues = restrictionPropertyValues(keys);
    inCondition.put(QueryOperators.IN, restrictionPropertyValues);
    query.put(getRestrictionPropertyName(), inCondition);

    DBCursor cur = dbCollection.find(query);

    List<T> foundResult = new ArrayList<T>();
    for (DBObject each : cur) {
        T eachResult = dataMapper.toDomain(each);
        foundResult.add(eachResult);//from  w  ww.  ja v a  2  s. c o  m
    }

    return foundResult;
}