Package com.mongodb

Examples of com.mongodb.DBRef


    DBObject mappedObject = mapper.getMappedObject(update.getUpdateObject(),
        context.getPersistentEntity(DocumentWithDBRefCollection.class));

    DBObject pullClause = getAsDBObject(mappedObject, "$pull");
    assertThat(pullClause.get("dbRefAnnotatedList"), is((Object) new DBRef(null, "entity", "2")));
  }
View Full Code Here


    Update update = new Update().pull("dbRefAnnotatedList", entity);
    DBObject mappedObject = mapper.getMappedObject(update.getUpdateObject(),
        context.getPersistentEntity(DocumentWithDBRefCollection.class));

    DBObject pullClause = getAsDBObject(mappedObject, "$pull");
    assertThat(pullClause.get("dbRefAnnotatedList"), is((Object) new DBRef(null, "entity", entity.id)));
  }
View Full Code Here

    Update update = new Update().set("dbRefProperty", entity);
    DBObject mappedObject = mapper.getMappedObject(update.getUpdateObject(),
        context.getPersistentEntity(DocumentWithDBRefCollection.class));

    DBObject setClause = getAsDBObject(mappedObject, "$set");
    assertThat(setClause.get("dbRefProperty"), is((Object) new DBRef(null, "entity", entity.id)));
  }
View Full Code Here

        context.getPersistentEntity(DocumentWithReferenceToInterfaceImpl.class));

    DBObject $set = DBObjectTestUtils.getAsDBObject(mappedObject, "$set");
    Object model = $set.get("referencedDocument");

    DBRef expectedDBRef = new DBRef(factory.getDb(), "interfaceDocumentDefinitionImpl", "1");
    assertThat(model, allOf(instanceOf(DBRef.class), IsEqual.<Object> equalTo(expectedDBRef)));
  }
View Full Code Here

  public void createsSimpleDBRefCorrectly() {

    Person person = new Person();
    person.id = "foo";

    DBRef dbRef = converter.toDBRef(person, null);
    assertThat(dbRef.getId(), is((Object) "foo"));
    assertThat(dbRef.getRef(), is("person"));
  }
View Full Code Here

    assertThat(map.get("test"), instanceOf(DBRef.class));

    DBObject mapValDBObject = new BasicDBObject();
    mapValDBObject.put("_id", BigInteger.ONE);

    DBRef dbRef = mock(DBRef.class);
    when(dbRef.fetch()).thenReturn(mapValDBObject);

    ((DBObject) dbObject.get("map")).put("test", dbRef);

    MapDBRef read = converter.read(MapDBRef.class, dbObject);
View Full Code Here

    MongoPersistentProperty property = mappingContext.getPersistentPropertyPath(path).getLeafProperty();

    Person person = new Person();
    person.id = "foo";

    DBRef dbRef = converter.toDBRef(person, property);
    assertThat(dbRef.getId(), is((Object) "foo"));
    assertThat(dbRef.getRef(), is("person"));
  }
View Full Code Here

    MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(ClassWithLazyDbRefs.class);
    MongoPersistentProperty property = entity.getPersistentProperty("dbRefToConcreteType");

    String idValue = new ObjectId().toString();
    DBRef dbRef = converter.toDBRef(new LazyDbRefTarget(idValue), property);

    DBObject object = new BasicDBObject("dbRefToConcreteType", dbRef);

    ClassWithLazyDbRefs result = converter.read(ClassWithLazyDbRefs.class, object);
View Full Code Here

    MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(ClassWithLazyDbRefs.class);
    MongoPersistentProperty property = entity.getPersistentProperty("dbRefToConcreteTypeWithPropertyAccess");

    String idValue = new ObjectId().toString();
    DBRef dbRef = converter.toDBRef(new LazyDbRefTargetPropertyAccess(idValue), property);

    DBObject object = new BasicDBObject("dbRefToConcreteTypeWithPropertyAccess", dbRef);

    ClassWithLazyDbRefs result = converter.read(ClassWithLazyDbRefs.class, object);
View Full Code Here

    MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(WithObjectMethodOverrideLazyDbRefs.class);
    MongoPersistentProperty property = entity.getPersistentProperty("dbRefToConcreteTypeWithPropertyAccess");

    String idValue = new ObjectId().toString();
    DBRef dbRef = converter.toDBRef(new LazyDbRefTargetPropertyAccess(idValue), property);

    WithObjectMethodOverrideLazyDbRefs result = converter.read(WithObjectMethodOverrideLazyDbRefs.class,
        new BasicDBObject("dbRefToPlainObject", dbRef));

    ReflectionTestUtils.invokeMethod(result.dbRefToPlainObject, "finalize");
View Full Code Here

TOP

Related Classes of com.mongodb.DBRef

Copyright © 2018 www.massapicom. 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.