Package org.nutz.mongo.entity

Examples of org.nutz.mongo.entity.MongoEntity.toObject()


      if (null != v) {
        // 如果是 DBObject
        if (v instanceof DBObject) {
          MongoEntity en = Mongos.entity(eleType);
          if (en instanceof StaticMongoEntity) {
            o = en.toObject((DBObject) v);
          } else
            o = Lang.map2Object(((DBObject) v).toMap(), eleType);
        }
        // 否则就强制转换一下
        else {
View Full Code Here


    if (val instanceof DBRef && field.isRef()) {
      return unpackRef((DBRef)val, field.getType());
    }
    MongoEntity en = Mongos.entity(field.getMirror().getType());
    if (en instanceof StaticMongoEntity)
      return en.toObject((DBObject) val);
    Map<String, Object> map = (Map<String, Object>) ((DBObject) val).toMap();
    return Lang.map2Object(map, field.getType());
  }

}
View Full Code Here

      DBCollection coll = db.getCollection(collName);
      // 将 ref 对象转换成 DBObject
      DBObject dbRef = moe.formatObject(q);
      DBObject dbo = null == dbRef ? coll.findOne() : coll.findOne(dbRef);
      // 执行转换
      return (T) moe.toObject(dbo);
    }
    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.