Merge branch 'DATACASS-32' of https://github.com/shvid/spring-data-cassandra into DATACASS-32
This commit is contained in:
@@ -105,6 +105,22 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> T insert(T entity, String tableName, QueryOptions options);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
<T> T insert(T entity, QueryOptions options);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
<T> T insert(T entity, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
@@ -130,6 +146,22 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> List<T> insert(List<T> entities, String tableName);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
<T> List<T> insert(List<T> entities, QueryOptions options);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
* @param optionsByName
|
||||
* @return
|
||||
*/
|
||||
<T> List<T> insert(List<T> entities, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
@@ -160,6 +192,22 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> T insertAsynchronously(T entity, String tableName);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
<T> T insertAsynchronously(T entity, QueryOptions options);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
* @param optionsByName
|
||||
* @return
|
||||
*/
|
||||
<T> T insertAsynchronously(T entity, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
@@ -190,6 +238,22 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> List<T> insertAsynchronously(List<T> entities, String tableName);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
<T> List<T> insertAsynchronously(List<T> entities, QueryOptions options);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
* @param optionsByName
|
||||
* @return
|
||||
*/
|
||||
<T> List<T> insertAsynchronously(List<T> entities, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
@@ -220,6 +284,22 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> T update(T entity, String tableName);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
<T> T update(T entity, QueryOptions options);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
* @param optionsByName
|
||||
* @return
|
||||
*/
|
||||
<T> T update(T entity, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
@@ -250,6 +330,22 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> List<T> update(List<T> entities, String tableName);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
<T> List<T> update(List<T> entities, QueryOptions options);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
* @param optionsByName
|
||||
* @return
|
||||
*/
|
||||
<T> List<T> update(List<T> entities, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
@@ -280,6 +376,22 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> T updateAsynchronously(T entity, String tableName);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
<T> T updateAsynchronously(T entity, QueryOptions options);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
* @param optionsByName
|
||||
* @return
|
||||
*/
|
||||
<T> T updateAsynchronously(T entity, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
@@ -310,6 +422,22 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> List<T> updateAsynchronously(List<T> entities, String tableName);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
<T> List<T> updateAsynchronously(List<T> entities, QueryOptions options);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
* @param optionsByName
|
||||
* @return
|
||||
*/
|
||||
<T> List<T> updateAsynchronously(List<T> entities, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
@@ -341,6 +469,20 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> void delete(T entity, String tableName);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
* @param options
|
||||
*/
|
||||
<T> void delete(T entity, QueryOptions options);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
* @param optionsByName
|
||||
*/
|
||||
<T> void delete(T entity, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
@@ -370,6 +512,20 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> void delete(List<T> entities, String tableName);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
* @param options
|
||||
*/
|
||||
<T> void delete(List<T> entities, QueryOptions options);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
* @param optionsByName
|
||||
*/
|
||||
<T> void delete(List<T> entities, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
@@ -391,6 +547,20 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> void deleteAsychronously(T entity);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
* @param options
|
||||
*/
|
||||
<T> void deleteAsychronously(T entity, QueryOptions options);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
* @param optionsByName
|
||||
*/
|
||||
<T> void deleteAsychronously(T entity, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @param tableName
|
||||
@@ -428,6 +598,20 @@ public interface CassandraOperations {
|
||||
*/
|
||||
<T> void deleteAsychronously(List<T> entities, String tableName);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
* @param options
|
||||
*/
|
||||
<T> void deleteAsychronously(List<T> entities, QueryOptions options);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
* @param optionsByName
|
||||
*/
|
||||
<T> void deleteAsychronously(List<T> entities, Map<String, Object> optionsByName);
|
||||
|
||||
/**
|
||||
* @param entities
|
||||
* @param tableName
|
||||
|
||||
@@ -53,7 +53,7 @@ import com.datastax.driver.core.exceptions.NoHostAvailableException;
|
||||
import com.datastax.driver.core.querybuilder.Batch;
|
||||
|
||||
/**
|
||||
* The Cassandra Template is a convenience API for all Cassnadta DML Operations.
|
||||
* The Cassandra Template is a convenience API for all Cassnadra DML Operations.
|
||||
*
|
||||
* @author Alex Shvid
|
||||
* @author David Webb
|
||||
@@ -128,6 +128,26 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
delete(entities, tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#delete(java.util.List, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> void delete(List<T> entities, Map<String, Object> optionsByName) {
|
||||
String tableName = getTableName(entities.get(0).getClass());
|
||||
Assert.notNull(tableName);
|
||||
delete(entities, tableName, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#delete(java.util.List, org.springframework.data.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> void delete(List<T> entities, QueryOptions options) {
|
||||
String tableName = getTableName(entities.get(0).getClass());
|
||||
Assert.notNull(tableName);
|
||||
delete(entities, tableName, options);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#delete(java.util.List, java.lang.String)
|
||||
*/
|
||||
@@ -166,6 +186,26 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
delete(entity, tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#delete(java.lang.Object, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> void delete(T entity, Map<String, Object> optionsByName) {
|
||||
String tableName = getTableName(entity.getClass());
|
||||
Assert.notNull(tableName);
|
||||
delete(entity, tableName, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#delete(java.lang.Object, org.springframework.data.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> void delete(T entity, QueryOptions options) {
|
||||
String tableName = getTableName(entity.getClass());
|
||||
Assert.notNull(tableName);
|
||||
delete(entity, tableName, options);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#delete(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
@@ -203,6 +243,26 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
deleteAsychronously(entities, tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#deleteAsychronously(java.util.List, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> void deleteAsychronously(List<T> entities, Map<String, Object> optionsByName) {
|
||||
String tableName = getTableName(entities.get(0).getClass());
|
||||
Assert.notNull(tableName);
|
||||
deleteAsychronously(entities, tableName, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#deleteAsychronously(java.util.List, org.springframework.data.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> void deleteAsychronously(List<T> entities, QueryOptions options) {
|
||||
String tableName = getTableName(entities.get(0).getClass());
|
||||
Assert.notNull(tableName);
|
||||
deleteAsychronously(entities, tableName, options);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#deleteAsychronously(java.util.List, java.lang.String)
|
||||
*/
|
||||
@@ -241,6 +301,26 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
deleteAsychronously(entity, tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#deleteAsychronously(java.lang.Object, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> void deleteAsychronously(T entity, Map<String, Object> optionsByName) {
|
||||
String tableName = getTableName(entity.getClass());
|
||||
Assert.notNull(tableName);
|
||||
deleteAsychronously(entity, tableName, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#deleteAsychronously(java.lang.Object, org.springframework.data.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> void deleteAsychronously(T entity, QueryOptions options) {
|
||||
String tableName = getTableName(entity.getClass());
|
||||
Assert.notNull(tableName);
|
||||
deleteAsychronously(entity, tableName, options);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#deleteAsychronously(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
@@ -400,6 +480,26 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
return insert(entities, tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#insert(java.util.List, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> insert(List<T> entities, Map<String, Object> optionsByName) {
|
||||
String tableName = getTableName(entities.get(0).getClass());
|
||||
Assert.notNull(tableName);
|
||||
return insert(entities, tableName, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#insert(java.util.List, org.springframework.data.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> insert(List<T> entities, QueryOptions options) {
|
||||
String tableName = getTableName(entities.get(0).getClass());
|
||||
Assert.notNull(tableName);
|
||||
return insert(entities, tableName, options);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#insert(java.util.List, java.lang.String)
|
||||
*/
|
||||
@@ -438,6 +538,26 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
return insert(entity, tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#insert(java.lang.Object, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> T insert(T entity, Map<String, Object> optionsByName) {
|
||||
String tableName = determineTableName(entity);
|
||||
Assert.notNull(tableName);
|
||||
return insert(entity, tableName, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#insert(java.lang.Object, org.springframework.data.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> T insert(T entity, QueryOptions options) {
|
||||
String tableName = determineTableName(entity);
|
||||
Assert.notNull(tableName);
|
||||
return insert(entity, tableName, options);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#insert(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
@@ -475,6 +595,26 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
return insertAsynchronously(entities, tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#insertAsynchronously(java.util.List, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> insertAsynchronously(List<T> entities, Map<String, Object> optionsByName) {
|
||||
String tableName = getTableName(entities.get(0).getClass());
|
||||
Assert.notNull(tableName);
|
||||
return insertAsynchronously(entities, tableName, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#insertAsynchronously(java.util.List, org.springframework.data.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> insertAsynchronously(List<T> entities, QueryOptions options) {
|
||||
String tableName = getTableName(entities.get(0).getClass());
|
||||
Assert.notNull(tableName);
|
||||
return insertAsynchronously(entities, tableName, options);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#insertAsynchronously(java.util.List, java.lang.String)
|
||||
*/
|
||||
@@ -513,6 +653,26 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
return insertAsynchronously(entity, tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#insertAsynchronously(java.lang.Object, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> T insertAsynchronously(T entity, Map<String, Object> optionsByName) {
|
||||
String tableName = determineTableName(entity);
|
||||
Assert.notNull(tableName);
|
||||
return insertAsynchronously(entity, tableName, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#insertAsynchronously(java.lang.Object, org.springframework.data.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> T insertAsynchronously(T entity, QueryOptions options) {
|
||||
String tableName = determineTableName(entity);
|
||||
Assert.notNull(tableName);
|
||||
return insertAsynchronously(entity, tableName, options);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#insertAsynchronously(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
@@ -576,6 +736,26 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
return update(entities, tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#update(java.util.List, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> update(List<T> entities, Map<String, Object> optionsByName) {
|
||||
String tableName = getTableName(entities.get(0).getClass());
|
||||
Assert.notNull(tableName);
|
||||
return update(entities, tableName, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#update(java.util.List, org.springframework.data.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> update(List<T> entities, QueryOptions options) {
|
||||
String tableName = getTableName(entities.get(0).getClass());
|
||||
Assert.notNull(tableName);
|
||||
return update(entities, tableName, options);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#update(java.util.List, java.lang.String)
|
||||
*/
|
||||
@@ -614,6 +794,26 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
return update(entity, tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#update(java.lang.Object, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> T update(T entity, Map<String, Object> optionsByName) {
|
||||
String tableName = getTableName(entity.getClass());
|
||||
Assert.notNull(tableName);
|
||||
return update(entity, tableName, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#update(java.lang.Object, org.springframework.data.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> T update(T entity, QueryOptions options) {
|
||||
String tableName = getTableName(entity.getClass());
|
||||
Assert.notNull(tableName);
|
||||
return update(entity, tableName, options);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#update(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
@@ -651,6 +851,26 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
return updateAsynchronously(entities, tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#updateAsynchronously(java.util.List, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> updateAsynchronously(List<T> entities, Map<String, Object> optionsByName) {
|
||||
String tableName = getTableName(entities.get(0).getClass());
|
||||
Assert.notNull(tableName);
|
||||
return updateAsynchronously(entities, tableName, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#updateAsynchronously(java.util.List, org.springframework.data.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> List<T> updateAsynchronously(List<T> entities, QueryOptions options) {
|
||||
String tableName = getTableName(entities.get(0).getClass());
|
||||
Assert.notNull(tableName);
|
||||
return updateAsynchronously(entities, tableName, options);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#updateAsynchronously(java.util.List, java.lang.String)
|
||||
*/
|
||||
@@ -689,6 +909,26 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
return updateAsynchronously(entity, tableName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#updateAsynchronously(java.lang.Object, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public <T> T updateAsynchronously(T entity, Map<String, Object> optionsByName) {
|
||||
String tableName = getTableName(entity.getClass());
|
||||
Assert.notNull(tableName);
|
||||
return updateAsynchronously(entity, tableName, optionsByName);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#updateAsynchronously(java.lang.Object, org.springframework.data.cassandra.core.QueryOptions)
|
||||
*/
|
||||
@Override
|
||||
public <T> T updateAsynchronously(T entity, QueryOptions options) {
|
||||
String tableName = getTableName(entity.getClass());
|
||||
Assert.notNull(tableName);
|
||||
return updateAsynchronously(entity, tableName, options);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.data.cassandra.core.CassandraOperations#updateAsynchronously(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
@@ -796,7 +1036,7 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
try {
|
||||
|
||||
final Batch b = CqlUtils.toInsertBatchQuery(keyspace.getKeyspace(), tableName, entities, CPEntity, optionsByName);
|
||||
log.info(b.toString());
|
||||
log.info(b.getQueryString());
|
||||
|
||||
return execute(new SessionCallback<List<T>>() {
|
||||
|
||||
@@ -922,6 +1162,12 @@ public class CassandraTemplate implements CassandraOperations {
|
||||
|
||||
final Query q = CqlUtils.toInsertQuery(keyspace.getKeyspace(), tableName, entity, CPEntity, optionsByName);
|
||||
log.info(q.toString());
|
||||
if (q.getConsistencyLevel() != null) {
|
||||
log.info(q.getConsistencyLevel().name());
|
||||
}
|
||||
if (q.getRetryPolicy() != null) {
|
||||
log.info(q.getRetryPolicy().toString());
|
||||
}
|
||||
|
||||
return execute(new SessionCallback<T>() {
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.data.mapping.PropertyHandler;
|
||||
import com.datastax.driver.core.ColumnMetadata;
|
||||
import com.datastax.driver.core.DataType;
|
||||
import com.datastax.driver.core.Query;
|
||||
import com.datastax.driver.core.Statement;
|
||||
import com.datastax.driver.core.TableMetadata;
|
||||
import com.datastax.driver.core.querybuilder.Batch;
|
||||
import com.datastax.driver.core.querybuilder.Delete;
|
||||
@@ -356,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));
|
||||
|
||||
}
|
||||
|
||||
@@ -392,11 +391,9 @@ 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));
|
||||
|
||||
}
|
||||
|
||||
@@ -514,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));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ import org.springframework.data.cassandra.mapping.RowId;
|
||||
import org.springframework.data.cassandra.mapping.Table;
|
||||
|
||||
/**
|
||||
* Test POJO
|
||||
*
|
||||
* @author David Webb
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.cassandra.config.TestConfig;
|
||||
import org.springframework.data.cassandra.core.CassandraTemplate;
|
||||
import org.springframework.data.cassandra.core.CassandraOperations;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
@@ -45,15 +45,15 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { TestConfig.class }, loader = AnnotationConfigContextLoader.class)
|
||||
public class CassandraOperationsTableTest {
|
||||
public class CassandraAdminTest {
|
||||
|
||||
@Autowired
|
||||
private CassandraTemplate cassandraTemplate;
|
||||
private CassandraOperations cassandraTemplate;
|
||||
|
||||
@Mock
|
||||
ApplicationContext context;
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(CassandraOperationsTableTest.class);
|
||||
private static Logger log = LoggerFactory.getLogger(CassandraAdminTest.class);
|
||||
|
||||
@BeforeClass
|
||||
public static void startCassandra() throws IOException, TTransportException, ConfigurationException,
|
||||
@@ -77,11 +77,6 @@ public class CassandraOperationsTableTest {
|
||||
DataLoader dataLoader = new DataLoader("Test Cluster", "localhost:9160");
|
||||
dataLoader.load(new ClassPathYamlDataSet("cassandra-keyspace.yaml"));
|
||||
|
||||
log.info("Creating Table...");
|
||||
|
||||
// cassandraTemplate.createTable(User.class);
|
||||
// cassandraTemplate.createTable(Comment.class);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -18,7 +18,11 @@ package org.springframework.data.cassandra.template;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.cassandra.exceptions.ConfigurationException;
|
||||
import org.apache.thrift.transport.TTransportException;
|
||||
@@ -29,7 +33,6 @@ import org.cassandraunit.dataset.yaml.ClassPathYamlDataSet;
|
||||
import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -39,6 +42,9 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.cassandra.config.TestConfig;
|
||||
import org.springframework.data.cassandra.core.CassandraOperations;
|
||||
import org.springframework.data.cassandra.core.ConsistencyLevel;
|
||||
import org.springframework.data.cassandra.core.QueryOptions;
|
||||
import org.springframework.data.cassandra.core.RetryPolicy;
|
||||
import org.springframework.data.cassandra.core.RingMember;
|
||||
import org.springframework.data.cassandra.table.Book;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -46,6 +52,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.AnnotationConfigContextLoader;
|
||||
|
||||
/**
|
||||
* Unit Tests for CassnadraTemplate
|
||||
*
|
||||
* @author David Webb
|
||||
*
|
||||
*/
|
||||
@@ -58,47 +66,29 @@ public class CassandraOperationsTest {
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(CassandraOperationsTest.class);
|
||||
|
||||
private final static String CASSANDRA_CONFIG = "cassandra.yaml";
|
||||
private final static String KEYSPACE_NAME = "test";
|
||||
private final static String CASSANDRA_HOST = "localhost";
|
||||
private final static int CASSANDRA_NATIVE_PORT = 9042;
|
||||
private final static int CASSANDRA_THRIFT_PORT = 9160;
|
||||
|
||||
@Rule
|
||||
public CassandraCQLUnit cassandraCQLUnit = new CassandraCQLUnit(new ClassPathCQLDataSet("cql-dataload.cql", "test"),
|
||||
"cassandra.yaml", "localhost", 9042);
|
||||
public CassandraCQLUnit cassandraCQLUnit = new CassandraCQLUnit(new ClassPathCQLDataSet("cql-dataload.cql",
|
||||
KEYSPACE_NAME), CASSANDRA_CONFIG, CASSANDRA_HOST, CASSANDRA_NATIVE_PORT);
|
||||
|
||||
@BeforeClass
|
||||
public static void startCassandra() throws IOException, TTransportException, ConfigurationException,
|
||||
InterruptedException {
|
||||
|
||||
EmbeddedCassandraServerHelper.startEmbeddedCassandra("cassandra.yaml");
|
||||
EmbeddedCassandraServerHelper.startEmbeddedCassandra(CASSANDRA_CONFIG);
|
||||
|
||||
/*
|
||||
* Load data file to creat the test keyspace before we init the template
|
||||
*/
|
||||
DataLoader dataLoader = new DataLoader("Test Cluster", "localhost:9160");
|
||||
DataLoader dataLoader = new DataLoader("Test Cluster", CASSANDRA_HOST + ":" + CASSANDRA_THRIFT_PORT);
|
||||
dataLoader.load(new ClassPathYamlDataSet("cassandra-keyspace.yaml"));
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setupKeyspace() {
|
||||
|
||||
/*
|
||||
* Load data file to creat the test keyspace before we init the template
|
||||
*/
|
||||
// DataLoader dataLoader = new DataLoader("Test Cluster", "localhost:9160");
|
||||
// dataLoader.load(new ClassPathYamlDataSet("cassandra-keyspace.yaml"));
|
||||
|
||||
log.info("Creating Table...");
|
||||
createTables();
|
||||
|
||||
}
|
||||
|
||||
private void createTables() {
|
||||
|
||||
// cassandraTemplate
|
||||
// .executeQuery("create table users (username text, firstName text, lastName text, PRIMARY KEY (username));");
|
||||
|
||||
// cassandraCQLUnit.
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ringTest() {
|
||||
|
||||
@@ -119,20 +109,254 @@ public class CassandraOperationsTest {
|
||||
public void insertTest() {
|
||||
|
||||
/*
|
||||
* Test Single Insert
|
||||
* Test Single Insert with entity
|
||||
*/
|
||||
Book b = new Book();
|
||||
b.setIsbn("123456");
|
||||
b.setTitle("Spring Data Cassandra Guide");
|
||||
b.setAuthor("Cassandra Guru");
|
||||
b.setPages(521);
|
||||
Book b1 = new Book();
|
||||
b1.setIsbn("123456-1");
|
||||
b1.setTitle("Spring Data Cassandra Guide");
|
||||
b1.setAuthor("Cassandra Guru");
|
||||
b1.setPages(521);
|
||||
|
||||
cassandraTemplate.insert(b);
|
||||
cassandraTemplate.insert(b1);
|
||||
|
||||
b.setPages(245);
|
||||
Book b2 = new Book();
|
||||
b2.setIsbn("123456-2");
|
||||
b2.setTitle("Spring Data Cassandra Guide");
|
||||
b2.setAuthor("Cassandra Guru");
|
||||
b2.setPages(521);
|
||||
|
||||
cassandraTemplate.update(b);
|
||||
cassandraTemplate.insert(b2, "book_alt");
|
||||
|
||||
/*
|
||||
* Test Single Insert with entity
|
||||
*/
|
||||
Book b3 = new Book();
|
||||
b3.setIsbn("123456-3");
|
||||
b3.setTitle("Spring Data Cassandra Guide");
|
||||
b3.setAuthor("Cassandra Guru");
|
||||
b3.setPages(265);
|
||||
|
||||
QueryOptions options = new QueryOptions();
|
||||
options.setConsistencyLevel(ConsistencyLevel.ONE);
|
||||
options.setRetryPolicy(RetryPolicy.DOWNGRADING_CONSISTENCY);
|
||||
|
||||
cassandraTemplate.insert(b3, "book", options);
|
||||
|
||||
/*
|
||||
* Test Single Insert with entity
|
||||
*/
|
||||
Book b4 = new Book();
|
||||
b4.setIsbn("123456-4");
|
||||
b4.setTitle("Spring Data Cassandra Guide");
|
||||
b4.setAuthor("Cassandra Guru");
|
||||
b4.setPages(465);
|
||||
|
||||
Map<String, Object> optionsByName = new HashMap<String, Object>();
|
||||
optionsByName.put(QueryOptions.QueryOptionMapKeys.CONSISTENCY_LEVEL, ConsistencyLevel.ALL);
|
||||
optionsByName.put(QueryOptions.QueryOptionMapKeys.RETRY_POLICY, RetryPolicy.FALLTHROUGH);
|
||||
optionsByName.put(QueryOptions.QueryOptionMapKeys.TTL, 30);
|
||||
|
||||
cassandraTemplate.insert(b4, "book", optionsByName);
|
||||
|
||||
/*
|
||||
* Test Single Insert with entity
|
||||
*/
|
||||
Book b5 = new Book();
|
||||
b5.setIsbn("123456-5");
|
||||
b5.setTitle("Spring Data Cassandra Guide");
|
||||
b5.setAuthor("Cassandra Guru");
|
||||
b5.setPages(265);
|
||||
|
||||
cassandraTemplate.insert(b5, options);
|
||||
|
||||
/*
|
||||
* Test Single Insert with entity
|
||||
*/
|
||||
Book b6 = new Book();
|
||||
b6.setIsbn("123456-6");
|
||||
b6.setTitle("Spring Data Cassandra Guide");
|
||||
b6.setAuthor("Cassandra Guru");
|
||||
b6.setPages(465);
|
||||
|
||||
cassandraTemplate.insert(b6, optionsByName);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void insertAsynchronouslyTest() {
|
||||
|
||||
/*
|
||||
* Test Single Insert with entity
|
||||
*/
|
||||
Book b1 = new Book();
|
||||
b1.setIsbn("123456-1");
|
||||
b1.setTitle("Spring Data Cassandra Guide");
|
||||
b1.setAuthor("Cassandra Guru");
|
||||
b1.setPages(521);
|
||||
|
||||
cassandraTemplate.insertAsynchronously(b1);
|
||||
|
||||
Book b2 = new Book();
|
||||
b2.setIsbn("123456-2");
|
||||
b2.setTitle("Spring Data Cassandra Guide");
|
||||
b2.setAuthor("Cassandra Guru");
|
||||
b2.setPages(521);
|
||||
|
||||
cassandraTemplate.insertAsynchronously(b2, "book_alt");
|
||||
|
||||
/*
|
||||
* Test Single Insert with entity
|
||||
*/
|
||||
Book b3 = new Book();
|
||||
b3.setIsbn("123456-3");
|
||||
b3.setTitle("Spring Data Cassandra Guide");
|
||||
b3.setAuthor("Cassandra Guru");
|
||||
b3.setPages(265);
|
||||
|
||||
QueryOptions options = new QueryOptions();
|
||||
options.setConsistencyLevel(ConsistencyLevel.ONE);
|
||||
options.setRetryPolicy(RetryPolicy.DOWNGRADING_CONSISTENCY);
|
||||
|
||||
cassandraTemplate.insertAsynchronously(b3, "book", options);
|
||||
|
||||
/*
|
||||
* Test Single Insert with entity
|
||||
*/
|
||||
Book b4 = new Book();
|
||||
b4.setIsbn("123456-4");
|
||||
b4.setTitle("Spring Data Cassandra Guide");
|
||||
b4.setAuthor("Cassandra Guru");
|
||||
b4.setPages(465);
|
||||
|
||||
Map<String, Object> optionsByName = new HashMap<String, Object>();
|
||||
optionsByName.put(QueryOptions.QueryOptionMapKeys.CONSISTENCY_LEVEL, ConsistencyLevel.ALL);
|
||||
optionsByName.put(QueryOptions.QueryOptionMapKeys.RETRY_POLICY, RetryPolicy.FALLTHROUGH);
|
||||
optionsByName.put(QueryOptions.QueryOptionMapKeys.TTL, 30);
|
||||
|
||||
cassandraTemplate.insertAsynchronously(b4, "book", optionsByName);
|
||||
|
||||
/*
|
||||
* Test Single Insert with entity
|
||||
*/
|
||||
Book b5 = new Book();
|
||||
b5.setIsbn("123456-5");
|
||||
b5.setTitle("Spring Data Cassandra Guide");
|
||||
b5.setAuthor("Cassandra Guru");
|
||||
b5.setPages(265);
|
||||
|
||||
cassandraTemplate.insertAsynchronously(b5, options);
|
||||
|
||||
/*
|
||||
* Test Single Insert with entity
|
||||
*/
|
||||
Book b6 = new Book();
|
||||
b6.setIsbn("123456-6");
|
||||
b6.setTitle("Spring Data Cassandra Guide");
|
||||
b6.setAuthor("Cassandra Guru");
|
||||
b6.setPages(465);
|
||||
|
||||
cassandraTemplate.insertAsynchronously(b6, optionsByName);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void insertBatchTest() {
|
||||
|
||||
QueryOptions options = new QueryOptions();
|
||||
options.setConsistencyLevel(ConsistencyLevel.ONE);
|
||||
options.setRetryPolicy(RetryPolicy.DOWNGRADING_CONSISTENCY);
|
||||
|
||||
Map<String, Object> optionsByName = new HashMap<String, Object>();
|
||||
optionsByName.put(QueryOptions.QueryOptionMapKeys.CONSISTENCY_LEVEL, ConsistencyLevel.ALL);
|
||||
optionsByName.put(QueryOptions.QueryOptionMapKeys.RETRY_POLICY, RetryPolicy.FALLTHROUGH);
|
||||
optionsByName.put(QueryOptions.QueryOptionMapKeys.TTL, 30);
|
||||
|
||||
List<Book> books = null;
|
||||
|
||||
books = getBookList(20);
|
||||
|
||||
cassandraTemplate.insert(books);
|
||||
|
||||
books = getBookList(20);
|
||||
|
||||
cassandraTemplate.insert(books, "book_alt");
|
||||
|
||||
books = getBookList(20);
|
||||
|
||||
cassandraTemplate.insert(books, "book", options);
|
||||
|
||||
books = getBookList(20);
|
||||
|
||||
cassandraTemplate.insert(books, "book", optionsByName);
|
||||
|
||||
books = getBookList(20);
|
||||
|
||||
cassandraTemplate.insert(books, options);
|
||||
|
||||
books = getBookList(20);
|
||||
|
||||
cassandraTemplate.insert(books, optionsByName);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void insertBatchAsynchronouslyTest() {
|
||||
|
||||
QueryOptions options = new QueryOptions();
|
||||
options.setConsistencyLevel(ConsistencyLevel.ONE);
|
||||
options.setRetryPolicy(RetryPolicy.DOWNGRADING_CONSISTENCY);
|
||||
|
||||
Map<String, Object> optionsByName = new HashMap<String, Object>();
|
||||
optionsByName.put(QueryOptions.QueryOptionMapKeys.CONSISTENCY_LEVEL, ConsistencyLevel.ALL);
|
||||
optionsByName.put(QueryOptions.QueryOptionMapKeys.RETRY_POLICY, RetryPolicy.FALLTHROUGH);
|
||||
optionsByName.put(QueryOptions.QueryOptionMapKeys.TTL, 30);
|
||||
|
||||
List<Book> books = null;
|
||||
|
||||
books = getBookList(20);
|
||||
|
||||
cassandraTemplate.insertAsynchronously(books);
|
||||
|
||||
books = getBookList(20);
|
||||
|
||||
cassandraTemplate.insertAsynchronously(books, "book_alt");
|
||||
|
||||
books = getBookList(20);
|
||||
|
||||
cassandraTemplate.insertAsynchronously(books, "book", options);
|
||||
|
||||
books = getBookList(20);
|
||||
|
||||
cassandraTemplate.insertAsynchronously(books, "book", optionsByName);
|
||||
|
||||
books = getBookList(20);
|
||||
|
||||
cassandraTemplate.insertAsynchronously(books, options);
|
||||
|
||||
books = getBookList(20);
|
||||
|
||||
cassandraTemplate.insertAsynchronously(books, optionsByName);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private List<Book> getBookList(int numBooks) {
|
||||
|
||||
List<Book> books = new ArrayList<Book>();
|
||||
|
||||
Book b = null;
|
||||
for (int i = 0; i < numBooks; i++) {
|
||||
b = new Book();
|
||||
b.setIsbn(UUID.randomUUID().toString());
|
||||
b.setTitle("Spring Data Cassandra Guide");
|
||||
b.setAuthor("Cassandra Guru");
|
||||
b.setPages(i * 10 + 5);
|
||||
books.add(b);
|
||||
}
|
||||
|
||||
return books;
|
||||
}
|
||||
|
||||
@After
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
create table book (isbn text, title text, author text, pages int, PRIMARY KEY (isbn));
|
||||
create table book (isbn text, title text, author text, pages int, PRIMARY KEY (isbn));
|
||||
create table book_alt (isbn text, title text, author text, pages int, PRIMARY KEY (isbn));
|
||||
@@ -33,11 +33,11 @@
|
||||
<cassandra:keyspace id="cassandra-keyspace" name="${cassandra.keyspace}"
|
||||
cassandra-cluster-ref="cassandra-cluster" cassandra-converter-ref="cassandra-converter">
|
||||
<cassandra:keyspace-attributes auto="update" replication-stategy="SimpleStrategy" replication-factor="1" durable-writes="true">
|
||||
<cassandra:table entity="org.springframework.data.cassandra.test.Comment" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.test.Notification" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.test.Post" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.test.Timeline" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.test.User" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.table.Comment" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.table.Notification" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.table.Post" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.table.Timeline" />
|
||||
<cassandra:table entity="org.springframework.data.cassandra.table.User" />
|
||||
</cassandra:keyspace-attributes>
|
||||
</cassandra:keyspace>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user