Package com.mongodb

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


      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

      if (element == null) {
        continue;
      }

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

    return dbList;
  }
View Full Code Here

      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

   * @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

   * @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

   * @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

   */
  @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

   */
  @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

   */
  @Test
  public void readShouldRespectExplicitFieldNameForDbRef() {

    BasicDBObject source = new BasicDBObject();
    source.append("explict-name-for-db-ref", new DBRef(mock(DB.class), "foo", "1"));

    converter.read(ClassWithExplicitlyNamedDBRefProperty.class, source);

    verify(resolver, times(1)).resolveDbRef(Mockito.any(MongoPersistentProperty.class), Mockito.any(DBRef.class),
        Mockito.any(DbRefResolverCallback.class), Mockito.any(DbRefProxyHandler.class));
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.