Examples of DBRef


Examples of com.mongodb.DBRef

      MongoPersistentEntity<?> entity, Object id) {

    DB db = mongoDbFactory.getDb();
    db = annotation != null && StringUtils.hasText(annotation.db()) ? mongoDbFactory.getDb(annotation.db()) : db;

    return new DBRef(db, entity.getCollection(), id);
  }
View Full Code Here

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

Examples of com.mongodb.DBRef

    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

Examples of com.mongodb.DBRef

    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

Examples of com.mongodb.DBRef

        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

Examples of com.mongodb.DBRef

  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

Examples of com.mongodb.DBRef

    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

Examples of com.mongodb.DBRef

    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

Examples of com.mongodb.DBRef

    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

Examples of com.mongodb.DBRef

    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
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.