Package com.mongodb

Examples of com.mongodb.DBCollection.findOne()


       
        assertEquals("Response isn't of type WriteResult", WriteResult.class, result.getClass());
       
        DBCollection dynamicCollection = db.getCollection("otherCollection");
       
        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledCollectionOnly");
        assertNotNull("No record with 'testInsertDynamicityEnabledCollectionOnly' _id", b);
       
        b = testCollection.findOne("testInsertDynamicityEnabledDBOnly");
        assertNull("There is a record with 'testInsertDynamicityEnabledCollectionOnly' _id in the test collection", b);
       
View Full Code Here


       
        assertEquals("Response isn't of type WriteResult", WriteResult.class, result.getClass());
       
        DBCollection dynamicCollection = mongo.getDB("otherDB").getCollection("otherCollection");
       
        DBObject b = dynamicCollection.findOne("testInsertDynamicityEnabledDBAndCollection");
        assertNotNull("No record with 'testInsertDynamicityEnabledDBAndCollection' _id", b);
       
        b = testCollection.findOne("testInsertDynamicityEnabledDBOnly");
        assertNull("There is a record with 'testInsertDynamicityEnabledDBAndCollection' _id in the test collection", b);
       
View Full Code Here

        Object o = exchange.getIn().getMandatoryBody();
        DBObject ret;
       
        DBObject fieldFilter = exchange.getIn().getHeader(MongoDbConstants.FIELDS_FILTER, DBObject.class);
        if (fieldFilter == null) {
            ret = dbCol.findOne(o);
        } else {
            ret = dbCol.findOne(o, fieldFilter);
        }
   
        Message out = exchange.getOut();
View Full Code Here

       
        DBObject fieldFilter = exchange.getIn().getHeader(MongoDbConstants.FIELDS_FILTER, DBObject.class);
        if (fieldFilter == null) {
            ret = dbCol.findOne(o);
        } else {
            ret = dbCol.findOne(o, fieldFilter);
        }
   
        Message out = exchange.getOut();
        out.setBody(ret);
        out.setHeader(MongoDbConstants.RESULT_TOTAL_SIZE, ret == null ? 0 : 1);
View Full Code Here

        DBObject o = exchange.getIn().getMandatoryBody(DBObject.class);
        DBObject ret;

        DBObject fieldFilter = exchange.getIn().getHeader(MongoDbConstants.FIELDS_FILTER, DBObject.class);
        if (fieldFilter == null) {
            ret = dbCol.findOne(o);
        } else {
            ret = dbCol.findOne(o, fieldFilter);
        }
       
        Message out = exchange.getOut();
View Full Code Here

        DBObject fieldFilter = exchange.getIn().getHeader(MongoDbConstants.FIELDS_FILTER, DBObject.class);
        if (fieldFilter == null) {
            ret = dbCol.findOne(o);
        } else {
            ret = dbCol.findOne(o, fieldFilter);
        }
       
        Message out = exchange.getOut();
        out.setBody(ret);
        out.setHeader(MongoDbConstants.RESULT_TOTAL_SIZE, ret == null ? 0 : 1);
View Full Code Here

        DBObject o = exchange.getIn().getMandatoryBody(DBObject.class);
        DBObject ret;

        DBObject fieldFilter = exchange.getIn().getHeader(MongoDbConstants.FIELDS_FILTER, DBObject.class);
        if (fieldFilter == null) {
            ret = dbCol.findOne(o);
        } else {
            ret = dbCol.findOne(o, fieldFilter);
        }

        Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.findOneByQuery);
View Full Code Here

        DBObject fieldFilter = exchange.getIn().getHeader(MongoDbConstants.FIELDS_FILTER, DBObject.class);
        if (fieldFilter == null) {
            ret = dbCol.findOne(o);
        } else {
            ret = dbCol.findOne(o, fieldFilter);
        }

        Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.findOneByQuery);
        resultMessage.setBody(ret);
        resultMessage.setHeader(MongoDbConstants.RESULT_TOTAL_SIZE, ret == null ? 0 : 1);
View Full Code Here

    @CheckForNull
    <T extends Document> T findUncached(Collection<T> collection, String key) {
        DBCollection dbCollection = getDBCollection(collection);
        long start = start();
        try {
            DBObject obj = dbCollection.findOne(getByKeyQuery(key).get());
            if (obj == null) {
                return null;
            }
            T doc = convertFromDBObject(collection, obj);
            if (doc != null) {
View Full Code Here

        List<FilterItem> whereItems = new ArrayList<FilterItem>();
        SelectItem selectItem = new SelectItem(primaryKeyColumn);
        FilterItem primaryKeyWhereItem = new FilterItem(selectItem, OperatorType.EQUALS_TO, keyValue);
        whereItems.add(primaryKeyWhereItem);
        final DBObject query = createMongoDbQuery(table, whereItems);
        final DBObject resultDBObject = collection.findOne(query);

        DataSetHeader header = new SimpleDataSetHeader(selectItems);

        Row row = MongoDBUtils.toRow(resultDBObject, header);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.