From fa7a5d240123f0fc984fe7c4782832f2e2305fa0 Mon Sep 17 00:00:00 2001 From: dwebb Date: Fri, 15 Nov 2013 15:31:43 -0500 Subject: [PATCH] wip: fixed and simplified the toBatchXXX() methods. --- .../data/cassandra/util/CqlUtils.java | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/springframework/data/cassandra/util/CqlUtils.java b/src/main/java/org/springframework/data/cassandra/util/CqlUtils.java index 1b21cccf6..90cfe1610 100644 --- a/src/main/java/org/springframework/data/cassandra/util/CqlUtils.java +++ b/src/main/java/org/springframework/data/cassandra/util/CqlUtils.java @@ -357,11 +357,9 @@ public abstract class CqlUtils { */ final Batch b = QueryBuilder.batch(); - List queries = new ArrayList(); - 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 queries = new ArrayList(); - 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 queries = new ArrayList(); - for (final T objectToSave : entities) { - queries.add(toDeleteQuery(keyspaceName, tableName, objectToSave, entity, optionsByName)); + b.add((Statement) toDeleteQuery(keyspaceName, tableName, objectToSave, entity, optionsByName)); }