本文整理汇总了Java中com.mongodb.DBObject.removeField方法的典型用法代码示例。如果您正苦于以下问题:Java DBObject.removeField方法的具体用法?Java DBObject.removeField怎么用?Java DBObject.removeField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mongodb.DBObject
的用法示例。
在下文中一共展示了DBObject.removeField方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insert
import com.mongodb.DBObject; //导入方法依赖的package包/类
public void insert(List<CanalEntry.Column> data, String schemaName, String tableName) {
DBObject obj = DBConvertUtil.columnToJson(data);
logger.debug("insert :{}", obj.toString());
//订单库单独处理
if (schemaName.equals("order")) {
//保存原始数据
if (tableName.startsWith("order_base_info")) {
tableName = "order_base_info";
} else if (tableName.startsWith("order_detail_info")) {
tableName = "order_detail_info";
} else {
logger.info("unknown data :{}.{}:{}", schemaName, tableName, obj);
return;
}
insertData(schemaName, tableName, obj, obj);
} else {
DBObject newObj = (DBObject) ObjectUtils.clone(obj);
if (newObj.containsField("id")) {
newObj.put("_id", newObj.get("id"));
newObj.removeField("id");
}
insertData(schemaName, tableName, newObj, obj);
}
}
示例2: updateData
import com.mongodb.DBObject; //导入方法依赖的package包/类
public void updateData(String schemaName, String tableName, DBObject query, DBObject obj) {
String path = "/" + schemaName + "/" + tableName + "/" + CanalEntry.EventType.UPDATE.getNumber();
int i = 0;
DBObject newObj = (DBObject) ObjectUtils.clone(obj);
DBObject logObj = (DBObject) ObjectUtils.clone(obj);
//保存原始数据
try {
obj.removeField("id");
i++;
naiveMongoTemplate.getCollection(tableName).update(query, obj);
i++;
SpringUtil.doEvent(path, newObj);
i++;
} catch (MongoClientException | MongoSocketException clientException) {
//客户端连接异常抛出,阻塞同步,防止mongodb宕机
throw clientException;
} catch (Exception e) {
logError(schemaName, tableName, 2, i, logObj, e);
}
}
示例3: update
import com.mongodb.DBObject; //导入方法依赖的package包/类
public Update update(Employee emlpoyee) {
DBObject empDBObject = (DBObject) mongoTemplate.getConverter().convertToMongoType(emlpoyee);
empDBObject.removeField(EMPLOYEE_FIELDS.ID);
return Update.fromDBObject(new BasicDBObject(key, empDBObject));
}