Package com.mongodb

Examples of com.mongodb.BasicDBObject.containsField()


    if (explain && !result.containsField(EXPLAIN)) {
      result.put(EXPLAIN, explain);
    }

    if (cursor != null && !result.containsField(CURSOR)) {
      result.put("cursor", cursor);
    }

    return result;
  }
View Full Code Here


    person.firstname = "Oliver";

    DBObject result = new BasicDBObject();
    converter.write(person, result);

    assertThat(result.containsField("foo"), is(true));
    assertThat(result.containsField("firstname"), is(false));
  }

  /**
   * @see DATAMONGO-144
View Full Code Here

    DBObject result = new BasicDBObject();
    converter.write(person, result);

    assertThat(result.containsField("foo"), is(true));
    assertThat(result.containsField("firstname"), is(false));
  }

  /**
   * @see DATAMONGO-144
   */
 
View Full Code Here

    Map<String, List<Locale>> map = Collections.singletonMap("Foo", Arrays.asList(Locale.US));
    DBObject result = new BasicDBObject();
    converter.write(map, result);

    assertThat(result.containsField("Foo"), is(true));
    assertThat(result.get("Foo"), is(notNullValue()));
    assertThat(result.get("Foo"), is(instanceOf(BasicDBList.class)));

    BasicDBList list = (BasicDBList) result.get("Foo");
View Full Code Here

    DBObject dbObject = new BasicDBObject();
    converter.write(Collections.singletonMap("foo.bar", "foobar"), dbObject);

    assertThat((String) dbObject.get("foo~bar"), is("foobar"));
    assertThat(dbObject.containsField("foo.bar"), is(false));
  }

  /**
   * @see DATAMONGO-380
   */
 
View Full Code Here

  @Test
  public void foo() {
    DBObject dbObject = new BasicDBObject();
    dbObject.put("foo", null);

    Assert.assertThat(dbObject.containsField("foo"), CoreMatchers.is(true));
  }

  public static class Foo {
    @Id public String id;
    public Bar bar;
View Full Code Here

  public void savesPlainDbObjectCorrectly() {

    DBObject dbObject = new BasicDBObject("foo", "bar");
    template.save(dbObject, "collection");

    assertThat(dbObject.containsField("_id"), is(true));
  }

  /**
   * @see DATAMONGO-550
   */
 
View Full Code Here

        toSet.put(LockDef.INACTIVE_LOCK_TIMEOUT.field, pLockOptions.getInactiveLockTimeout());

        final BasicDBObject lockDoc
        = (BasicDBObject)getDbCollection(pMongo, pSvcOptions).findAndModify(query, new BasicDBObject(LockDef.ID.field, 1), null, false, new BasicDBObject(SET, toSet), false, false);

        if (lockDoc != null && lockDoc.containsField(LockDef.ID.field)) {

            if (pSvcOptions.getEnableHistory())
            { LockHistoryDao.insert( pMongo, pLockName, pSvcOptions, pLockOptions, serverTime, LockState.LOCKED, lockId, false); }

            return lockId;
View Full Code Here

   */
  public static Object fetchDBRef(DB db, Object obj) {
    if (BasicDBObject.class.isInstance(obj)) {
      BasicDBObject dbObject = BasicDBObject.class.cast(obj);
      if (isRef(dbObject)
        && (!dbObject.containsField("$db")
        || dbObject.get("$db").equals(db.getName()))) {
        return new DBRef(db, dbObject).fetch();
      }
    }
    return obj;
View Full Code Here

        // Try and modify the existing lock.
        final BasicDBObject lockDoc
        = (BasicDBObject)getDbCollection(pMongo, pSvcOptions).findAndModify(query, new BasicDBObject(LockDef.LOCK_ID.field, 1), null, false, new BasicDBObject(SET, toSet), true, false);

        if (lockDoc == null) return null;
        if (!lockDoc.containsField(LockDef.LOCK_ID.field)) return null;

        final ObjectId returnedLockId = lockDoc.getObjectId(LockDef.LOCK_ID.field);
        if (returnedLockId == null) return null;
        if (!returnedLockId.equals(lockId)) return 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.