本文整理匯總了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));
}