本文整理匯總了Java中com.datastax.driver.core.querybuilder.QueryBuilder.delete方法的典型用法代碼示例。如果您正苦於以下問題:Java QueryBuilder.delete方法的具體用法?Java QueryBuilder.delete怎麽用?Java QueryBuilder.delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.datastax.driver.core.querybuilder.QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder.delete方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: delete
import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public void delete(String keyspace, String table, JSONArray columns,
JSONObject where, ConsistencyLevel consistency_level)
throws MemnonException, IOException {
Delete.Selection selection = QueryBuilder.delete();
if (columns == null) {
selection.all();
} else {
Iterator columnIterator = columns.iterator();
while (columnIterator.hasNext()) {
selection.column((String) columnIterator.next());
}
}
Delete statement = selection.from(table);
Iterator whereIterator = where.entrySet().iterator();
while (whereIterator.hasNext()) {
Map.Entry pair = (Map.Entry) whereIterator.next();
Clause clause = QueryBuilder.eq((String) pair.getKey(),
pair.getValue());
statement.where(clause);
}
executeStatement(keyspace, statement);
}
示例2: diffMap
import com.datastax.driver.core.querybuilder.QueryBuilder; //導入方法依賴的package包/類
private Collection<RegularStatement> diffMap(String table, String column, Clause whereClause, Map<?, ?> past,
Map<?, ?> present) {
List<RegularStatement> queries = Lists.newArrayList();
Set<?> removed = Sets.newHashSet(past.keySet());
removed.removeAll(present.keySet());
if (!removed.isEmpty()) {
Delete.Selection delete = QueryBuilder.delete();
for (Object o : removed) {
delete.mapElt(column, o);
}
queries.add(delete.from(table).where(whereClause));
}
Set<Entry<?, ?>> changed = Sets.<Entry<?, ?>> newHashSet(present.entrySet());
changed.removeAll(past.entrySet());
if (!changed.isEmpty()) {
Update update = QueryBuilder.update(table);
for (Entry<?, ?> entry : changed) {
update.with(QueryBuilder.put(column, entry.getKey(), entry.getValue()));
}
queries.add(update.where(whereClause));
}
return queries;
}