add truncate function to CassandraTemplate

This commit is contained in:
Alex Shvid
2013-11-27 11:39:11 -08:00
parent 0de5fc9a91
commit 73cb65c051
2 changed files with 18 additions and 0 deletions

View File

@@ -438,4 +438,11 @@ public interface CassandraOperations {
*/
void ingest(String cql, Object[][] rows);
/**
* Delete all rows in the table
*
* @param tableName
*/
void truncate(String tableName);
}

View File

@@ -38,6 +38,8 @@ import com.datastax.driver.core.ResultSetFuture;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.exceptions.DriverException;
import com.datastax.driver.core.querybuilder.QueryBuilder;
import com.datastax.driver.core.querybuilder.Truncate;
/**
* <b>This is the Central class in the Cassandra core package.</b> It simplifies the use of Cassandra and helps to avoid
@@ -616,4 +618,13 @@ public class CassandraTemplate extends CassandraAccessor implements CassandraOpe
});
}
/* (non-Javadoc)
* @see org.springframework.cassandra.core.CassandraOperations#truncate(java.lang.String)
*/
@Override
public void truncate(String tableName) throws DataAccessException {
Truncate truncate = QueryBuilder.truncate(tableName);
doExecute(truncate.getQueryString());
}
}