wip: fixed and simplified the toBatchXXX() methods.

This commit is contained in:
dwebb
2013-11-15 15:31:43 -05:00
parent 0b591a5a71
commit fa7a5d2401

View File

@@ -357,11 +357,9 @@ public abstract class CqlUtils {
*/
final Batch b = QueryBuilder.batch();
List<Query> queries = new ArrayList<Query>();
for (final T objectToSave : objectsToSave) {
queries.add(toUpdateQuery(keyspaceName, tableName, objectToSave, entity, optionsByName));
b.add((Statement) toUpdateQuery(keyspaceName, tableName, objectToSave, entity, optionsByName));
}
@@ -393,21 +391,12 @@ public abstract class CqlUtils {
*/
final Batch b = QueryBuilder.batch();
List<Query> queries = new ArrayList<Query>();
for (final T objectToSave : objectsToSave) {
queries.add(toInsertQuery(keyspaceName, tableName, objectToSave, entity, optionsByName));
b.add((Statement) toInsertQuery(keyspaceName, tableName, objectToSave, entity, optionsByName));
}
/*
* Add all the Queries to the batch
*/
for (Query query : queries) {
b.add((Statement) query);
}
addQueryOptions(b, optionsByName);
return b;
@@ -522,11 +511,9 @@ public abstract class CqlUtils {
*/
final Batch b = QueryBuilder.batch();
List<Query> queries = new ArrayList<Query>();
for (final T objectToSave : entities) {
queries.add(toDeleteQuery(keyspaceName, tableName, objectToSave, entity, optionsByName));
b.add((Statement) toDeleteQuery(keyspaceName, tableName, objectToSave, entity, optionsByName));
}