Examples of DBRef


Examples of com.mongodb.DBRef

    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

Examples of com.mongodb.DBRef

        if (value == null) {
          return;
        }

        DBRef dbref = value instanceof DBRef ? (DBRef) value : null;

        DbRefProxyHandler handler = new DefaultDbRefProxyHandler(spELContext, mappingContext,
            MappingMongoConverter.this);
        DbRefResolverCallback callback = new DefaultDbRefResolverCallback(dbo, currentPath, evaluator,
            MappingMongoConverter.this);
View Full Code Here

Examples of com.mongodb.DBRef

      return;
    }

    if (prop.isDbReference()) {

      DBRef dbRefObj = null;

      /*
       * If we already have a LazyLoadingProxy, we use it's cached DBRef value instead of
       * unnecessarily initializing it only to convert it to a DBRef a few instructions later.
       */
 
View Full Code Here

Examples of com.mongodb.DBRef

      if (element == null) {
        continue;
      }

      DBRef dbRef = createDBRef(element, property);
      dbList.add(dbRef);
    }

    return dbList;
  }
View Full Code Here

Examples of com.mongodb.DBRef

      return source;
    }

    if (source instanceof DBRef) {

      DBRef ref = (DBRef) source;
      return new DBRef(ref.getDB(), ref.getRef(), convertId(ref.getId()));
    }

    if (source instanceof Iterable) {
      BasicDBList result = new BasicDBList();
      for (Object element : (Iterable<?>) source) {
View Full Code Here

Examples of com.mongodb.DBRef

   * @see DATAMONGO-424
   */
  @Test
  public void readsPlainDBRefObject() {

    DBRef dbRef = new DBRef(mock(DB.class), "foo", 2);
    DBObject dbObject = new BasicDBObject("ref", dbRef);

    DBRefWrapper result = converter.read(DBRefWrapper.class, dbObject);
    assertThat(result.ref, is(dbRef));
  }
View Full Code Here

Examples of com.mongodb.DBRef

   * @see DATAMONGO-424
   */
  @Test
  public void readsCollectionOfDBRefs() {

    DBRef dbRef = new DBRef(mock(DB.class), "foo", 2);
    BasicDBList refs = new BasicDBList();
    refs.add(dbRef);

    DBObject dbObject = new BasicDBObject("refs", refs);

View Full Code Here

Examples of com.mongodb.DBRef

   * @see DATAMONGO-424
   */
  @Test
  public void readsDBRefMap() {

    DBRef dbRef = mock(DBRef.class);
    BasicDBObject refMap = new BasicDBObject("foo", dbRef);
    DBObject dbObject = new BasicDBObject("refMap", refMap);

    DBRefWrapper result = converter.read(DBRefWrapper.class, dbObject);

View Full Code Here

Examples of com.mongodb.DBRef

   */
  @Test
  @SuppressWarnings({ "rawtypes", "unchecked" })
  public void resolvesDBRefMapValue() {

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

    BasicDBObject refMap = new BasicDBObject("foo", dbRef);
    DBObject dbObject = new BasicDBObject("personMap", refMap);

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

Examples of com.mongodb.DBRef

   */
  @Test
  public void eagerlyReturnsDBRefObjectIfTargetAlreadyIsOne() {

    DB db = mock(DB.class);
    DBRef dbRef = new DBRef(db, "collection", "id");

    MongoPersistentProperty property = mock(MongoPersistentProperty.class);

    assertThat(converter.createDBRef(dbRef, property), is(dbRef));
  }
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.