Package com.mongodb

Examples of com.mongodb.DBCollection.findOne()


        writer.writeOid(RootOidDefault.deString(SPEC_NAME+":"+"D01", new OidMarshaller()));
        writer.flush();

        final DBCollection instances = testDb.getCollection(SPEC_NAME);
        assertEquals(1, instances.getCount());
        final DBObject object = instances.findOne();
       
        assertEquals(SPEC_NAME+":"+"D01", object.get("_oid"));
        assertEquals("D01", object.get("_id"));
       
        assertEquals(2, object.keySet().size());
View Full Code Here


        writer.writeField("string", "testing");
        writer.flush();

        final DBCollection instances = testDb.getCollection(SPEC_NAME);
        assertEquals(1, instances.getCount());
        final DBObject object = instances.findOne();
        assertEquals(SPEC_NAME+":"+"D01", object.get("_oid"));
        assertEquals("1023", object.get("number"));
        assertEquals("testing", object.get("string"));
    }
View Full Code Here

        writer.writeField("string", "testing");
        writer.flush();

        final DBCollection instances = testDb.getCollection(SPEC_NAME);
        assertEquals(1, instances.getCount());
        final DBObject object = instances.findOne();
        assertEquals(SPEC_NAME + ":" + "3", object.get("_oid"));
        assertEquals("1023", object.get("number"));
        assertEquals("testing", object.get("string"));
    }
View Full Code Here

    DBCollection collection = getCollection( key.getEntityKey() );
    DBObject searchObject = prepareIdObject( key.getEntityKey() );
    DBObject projection = getProjection( key, true );

    return collection.findOne( searchObject, projection, readPreference );
  }

  private DBObject getObject(EntityKey key, TupleContext tupleContext) {
    ReadPreference readPreference = getReadPreference( tupleContext );
View Full Code Here

    DBCollection collection = getCollection( key );
    DBObject searchObject = prepareIdObject( key );
    BasicDBObject projection = getProjection( tupleContext );

    return collection.findOne( searchObject, projection, readPreference );
  }

  private BasicDBObject getProjection(TupleContext tupleContext) {
    return getProjection( tupleContext.getSelectableColumns() );
  }
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

   
    Map<String, Object> findUncached(Collection collection, String key) {
        DBCollection dbCollection = getDBCollection(collection);
        long start = start();
        try {
            DBObject doc = dbCollection.findOne(getByKeyQuery(key).get());
            if (doc == null) {
                return null;
            }
            return convertFromDBObject(doc);
        } finally {
View Full Code Here

        while (true) {
            LOG.debug("Waiting for commit...");

            DBCollection headCollection = ((MongoNodeStore)microKernel.getNodeStore()).getSyncCollection();
            MongoSync syncMongo = (MongoSync) headCollection.findOne();
            if (this.lastHeadRevId < syncMongo.getHeadRevisionId()) {
                DBCollection commitCollection = ((MongoNodeStore)microKernel.getNodeStore()).getCommitCollection();
                DBObject query = QueryBuilder.start(MongoCommit.KEY_REVISION_ID).greaterThan(this.lastRevId)
                        .and(MongoCommit.KEY_REVISION_ID).lessThanEquals(syncMongo.getHeadRevisionId()).get();
                DBObject sort = QueryBuilder.start(MongoCommit.KEY_REVISION_ID).is(1).get();
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

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.