public class CassandraTemplate extends CqlTemplate implements CassandraOperations
CqlTemplate
.CqlTemplate
Modifier and Type | Class and Description |
---|---|
protected static interface |
CassandraTemplate.ClauseCallback |
Modifier and Type | Field and Description |
---|---|
protected CassandraConverter |
cassandraConverter |
protected CassandraMappingContext |
mappingContext |
log
logger
Constructor and Description |
---|
CassandraTemplate()
Default Constructor for wiring in the required components later
|
CassandraTemplate(com.datastax.driver.core.Session session) |
CassandraTemplate(com.datastax.driver.core.Session session,
CassandraConverter converter)
Constructor if only session and converter are known at time of Template Creation
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Ensure that the Cassandra Session has been set
|
protected void |
appendIdCriteria(CassandraTemplate.ClauseCallback clauseCallback,
CassandraPersistentEntity<?> entity,
Map<?,?> id) |
protected void |
appendIdCriteria(CassandraTemplate.ClauseCallback clauseCallback,
CassandraPersistentEntity<?> entity,
Object id) |
protected void |
appendIdCriteria(com.datastax.driver.core.querybuilder.Delete.Where where,
CassandraPersistentEntity<?> entity,
Object id) |
protected void |
appendIdCriteria(com.datastax.driver.core.querybuilder.Select.Where where,
CassandraPersistentEntity<?> entity,
Object id) |
protected <T> void |
batchDelete(List<T> entities,
QueryOptions options,
boolean asynchronously)
Perform the deletion on a list of objects
|
protected <T> List<T> |
batchInsert(List<T> entities,
WriteOptions options,
boolean asychronously) |
protected <T> List<T> |
batchUpdate(List<T> entities,
WriteOptions options,
boolean asychronously)
Update a Batch of rows in a Cassandra CQL Table
|
long |
count(Class<?> type) |
static <T> com.datastax.driver.core.querybuilder.Batch |
createDeleteBatchQuery(String tableName,
List<T> entities,
QueryOptions options,
EntityWriter<Object,Object> entityWriter)
Create a Batch Query object for multiple deletes.
|
static com.datastax.driver.core.querybuilder.Delete |
createDeleteQuery(String tableName,
Object object,
QueryOptions options,
EntityWriter<Object,Object> entityWriter)
Create a Delete Query Object from an annotated POJO
|
static <T> com.datastax.driver.core.querybuilder.Batch |
createInsertBatchQuery(String tableName,
List<T> entities,
WriteOptions options,
EntityWriter<Object,Object> entityWriter)
Generates a Batch Object for multiple inserts
|
static com.datastax.driver.core.querybuilder.Insert |
createInsertQuery(String tableName,
Object objectToSave,
WriteOptions options,
EntityWriter<Object,Object> entityWriter)
Generates a Query Object for an insert
|
<T> void |
delete(List<T> entities)
Remove the given object from the table by id.
|
<T> void |
delete(List<T> entities,
QueryOptions options) |
<T> void |
delete(T entity)
Remove the given object from the table by id.
|
<T> void |
delete(T entity,
QueryOptions options) |
protected <T> void |
delete(T entity,
QueryOptions options,
boolean asynchronously)
Perform the removal of a Row.
|
<T> void |
deleteAll(Class<T> clazz)
Deletes all entities of a given class.
|
<T> void |
deleteAsynchronously(List<T> entities)
Remove the given object from the table by id.
|
<T> void |
deleteAsynchronously(List<T> entities,
QueryOptions options) |
<T> void |
deleteAsynchronously(T entity)
Remove the given object from the table by id.
|
<T> void |
deleteAsynchronously(T entity,
QueryOptions options) |
void |
deleteById(Class<?> type,
Object id) |
protected <T> CqlIdentifier |
determineTableName(T obj) |
boolean |
exists(Class<?> type,
Object id) |
CassandraMappingContext |
getCassandraMappingContext() |
CassandraConverter |
getConverter()
Returns the underlying
CassandraConverter . |
CqlIdentifier |
getTableName(Class<?> type)
The table name used for the specified class by this template.
|
<T> List<T> |
insert(List<T> entities)
Insert the given list of objects to the table by annotation table name.
|
<T> List<T> |
insert(List<T> entities,
WriteOptions options) |
<T> T |
insert(T entity)
Insert the given object to the table by id.
|
<T> T |
insert(T entity,
WriteOptions options) |
protected <T> T |
insert(T entity,
WriteOptions options,
boolean asynchronously) |
<T> List<T> |
insertAsynchronously(List<T> entities)
Insert the given object to the table by id.
|
<T> List<T> |
insertAsynchronously(List<T> entities,
WriteOptions options) |
<T> T |
insertAsynchronously(T entity)
Insert the given object to the table by id.
|
<T> T |
insertAsynchronously(T entity,
WriteOptions options) |
protected <T> List<T> |
select(com.datastax.driver.core.querybuilder.Select query,
CassandraConverterRowCallback<T> readRowCallback) |
<T> List<T> |
select(com.datastax.driver.core.querybuilder.Select select,
Class<T> type)
Execute the Select Query and convert to the list of entities
|
protected <T> List<T> |
select(String query,
CassandraConverterRowCallback<T> readRowCallback) |
<T> List<T> |
select(String cql,
Class<T> type)
Execute query and convert ResultSet to the list of entities
|
<T> List<T> |
selectAll(Class<T> type) |
<T> List<T> |
selectBySimpleIds(Class<T> type,
Iterable<?> ids) |
protected <T> T |
selectOne(com.datastax.driver.core.querybuilder.Select query,
CassandraConverterRowCallback<T> readRowCallback) |
<T> T |
selectOne(com.datastax.driver.core.querybuilder.Select select,
Class<T> type)
Execute Select query and convert ResultSet to the entity
|
protected <T> T |
selectOne(String query,
CassandraConverterRowCallback<T> readRowCallback) |
<T> T |
selectOne(String cql,
Class<T> type)
Execute CQL and convert ResultSet to the entity
|
<T> T |
selectOneById(Class<T> type,
Object id) |
void |
setConverter(CassandraConverter cassandraConverter) |
static <T> com.datastax.driver.core.querybuilder.Batch |
toUpdateBatchQuery(String tableName,
List<T> objectsToSave,
WriteOptions options,
EntityWriter<Object,Object> entityWriter)
Generates a Batch Object for multiple Updates
|
static com.datastax.driver.core.querybuilder.Update |
toUpdateQuery(String tableName,
Object objectToSave,
WriteOptions options,
EntityWriter<Object,Object> entityWriter)
Generates a Query Object for an Update
|
<T> List<T> |
update(List<T> entities)
Insert the given object to the table by id.
|
<T> List<T> |
update(List<T> entities,
WriteOptions options) |
<T> T |
update(T entity)
Insert the given object to the table by id.
|
<T> T |
update(T entity,
WriteOptions options) |
protected <T> T |
update(T entity,
WriteOptions options,
boolean asychronously)
Update a row into a Cassandra CQL Table
|
<T> List<T> |
updateAsynchronously(List<T> entities)
Insert the given object to the table by id.
|
<T> List<T> |
updateAsynchronously(List<T> entities,
WriteOptions options) |
<T> T |
updateAsynchronously(T entity)
Insert the given object to the table by id.
|
<T> T |
updateAsynchronously(T entity,
WriteOptions options) |
addPreparedStatementOptions, addQueryOptions, addWriteOptions, addWriteOptions, count, count, describeRing, describeRing, doExecute, doExecute, doExecute, doExecute, doExecuteAsync, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, firstColumnToObject, getHosts, ingest, ingest, ingest, ingest, ingest, ingest, process, process, processList, processListOfMap, processMap, processOne, processOne, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryForList, queryForList, queryForListOfMap, queryForListOfMap, queryForMap, queryForMap, queryForObject, queryForObject, queryForObject, queryForObject, selectCount, toMap, translateExceptionIfPossible, translateExceptionIfPossible, truncate, truncate
getExceptionTranslator, getSession, setExceptionTranslator, setSession
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
count, count, describeRing, describeRing, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, execute, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, executeAsynchronously, getSession, ingest, ingest, ingest, ingest, ingest, ingest, process, process, processList, processListOfMap, processMap, processOne, processOne, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, query, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryAsynchronously, queryForList, queryForList, queryForListOfMap, queryForListOfMap, queryForMap, queryForMap, queryForObject, queryForObject, queryForObject, queryForObject, truncate, truncate
protected CassandraConverter cassandraConverter
protected CassandraMappingContext mappingContext
public CassandraTemplate()
public CassandraTemplate(com.datastax.driver.core.Session session)
public CassandraTemplate(com.datastax.driver.core.Session session, CassandraConverter converter)
session
- must not be nullconverter
- must not be null.public void setConverter(CassandraConverter cassandraConverter)
public CassandraConverter getConverter()
CassandraOperations
CassandraConverter
.getConverter
in interface CassandraOperations
public CassandraMappingContext getCassandraMappingContext()
public void afterPropertiesSet()
CassandraAccessor
afterPropertiesSet
in interface InitializingBean
afterPropertiesSet
in class CassandraAccessor
public boolean exists(Class<?> type, Object id)
exists
in interface CassandraOperations
public long count(Class<?> type)
count
in interface CassandraOperations
public <T> void delete(List<T> entities)
CassandraOperations
delete
in interface CassandraOperations
public <T> void delete(List<T> entities, QueryOptions options)
delete
in interface CassandraOperations
public void deleteById(Class<?> type, Object id)
deleteById
in interface CassandraOperations
public <T> void delete(T entity)
CassandraOperations
delete
in interface CassandraOperations
public <T> void delete(T entity, QueryOptions options)
delete
in interface CassandraOperations
public <T> void deleteAsynchronously(List<T> entities)
CassandraOperations
deleteAsynchronously
in interface CassandraOperations
public <T> void deleteAsynchronously(List<T> entities, QueryOptions options)
deleteAsynchronously
in interface CassandraOperations
public <T> void deleteAsynchronously(T entity)
CassandraOperations
deleteAsynchronously
in interface CassandraOperations
public <T> void deleteAsynchronously(T entity, QueryOptions options)
deleteAsynchronously
in interface CassandraOperations
public CqlIdentifier getTableName(Class<?> type)
CassandraOperations
getTableName
in interface CassandraOperations
type
- must not be null.public <T> List<T> insert(List<T> entities)
CassandraOperations
insert
in interface CassandraOperations
public <T> List<T> insert(List<T> entities, WriteOptions options)
insert
in interface CassandraOperations
public <T> T insert(T entity)
CassandraOperations
insert
in interface CassandraOperations
public <T> T insert(T entity, WriteOptions options)
insert
in interface CassandraOperations
public <T> List<T> insertAsynchronously(List<T> entities)
CassandraOperations
insertAsynchronously
in interface CassandraOperations
public <T> List<T> insertAsynchronously(List<T> entities, WriteOptions options)
insertAsynchronously
in interface CassandraOperations
public <T> T insertAsynchronously(T entity)
CassandraOperations
insertAsynchronously
in interface CassandraOperations
public <T> T insertAsynchronously(T entity, WriteOptions options)
insertAsynchronously
in interface CassandraOperations
public <T> List<T> selectAll(Class<T> type)
selectAll
in interface CassandraOperations
public <T> List<T> select(String cql, Class<T> type)
CassandraOperations
select
in interface CassandraOperations
type
- must not be null, mapped entity type.public <T> List<T> select(com.datastax.driver.core.querybuilder.Select select, Class<T> type)
CassandraOperations
select
in interface CassandraOperations
select
- must not be null.type
- must not be null, mapped entity type.public <T> List<T> selectBySimpleIds(Class<T> type, Iterable<?> ids)
selectBySimpleIds
in interface CassandraOperations
public <T> T selectOneById(Class<T> type, Object id)
selectOneById
in interface CassandraOperations
protected void appendIdCriteria(CassandraTemplate.ClauseCallback clauseCallback, CassandraPersistentEntity<?> entity, Map<?,?> id)
protected void appendIdCriteria(CassandraTemplate.ClauseCallback clauseCallback, CassandraPersistentEntity<?> entity, Object id)
protected void appendIdCriteria(com.datastax.driver.core.querybuilder.Select.Where where, CassandraPersistentEntity<?> entity, Object id)
protected void appendIdCriteria(com.datastax.driver.core.querybuilder.Delete.Where where, CassandraPersistentEntity<?> entity, Object id)
public <T> T selectOne(String cql, Class<T> type)
CassandraOperations
selectOne
in interface CassandraOperations
type
- must not be null, mapped entity type.public <T> T selectOne(com.datastax.driver.core.querybuilder.Select select, Class<T> type)
CassandraOperations
selectOne
in interface CassandraOperations
type
- must not be null, mapped entity type.public <T> List<T> update(List<T> entities)
CassandraOperations
update
in interface CassandraOperations
public <T> List<T> update(List<T> entities, WriteOptions options)
update
in interface CassandraOperations
public <T> T update(T entity)
CassandraOperations
update
in interface CassandraOperations
public <T> T update(T entity, WriteOptions options)
update
in interface CassandraOperations
public <T> List<T> updateAsynchronously(List<T> entities)
CassandraOperations
updateAsynchronously
in interface CassandraOperations
public <T> List<T> updateAsynchronously(List<T> entities, WriteOptions options)
updateAsynchronously
in interface CassandraOperations
public <T> T updateAsynchronously(T entity)
CassandraOperations
updateAsynchronously
in interface CassandraOperations
public <T> T updateAsynchronously(T entity, WriteOptions options)
updateAsynchronously
in interface CassandraOperations
protected <T> CqlIdentifier determineTableName(T obj)
protected <T> List<T> select(String query, CassandraConverterRowCallback<T> readRowCallback)
protected <T> List<T> select(com.datastax.driver.core.querybuilder.Select query, CassandraConverterRowCallback<T> readRowCallback)
protected <T> T selectOne(String query, CassandraConverterRowCallback<T> readRowCallback)
query
- readRowCallback
- protected <T> T selectOne(com.datastax.driver.core.querybuilder.Select query, CassandraConverterRowCallback<T> readRowCallback)
protected <T> void batchDelete(List<T> entities, QueryOptions options, boolean asynchronously)
tableName
- objectToRemove
- protected <T> T insert(T entity, WriteOptions options, boolean asynchronously)
protected <T> List<T> batchInsert(List<T> entities, WriteOptions options, boolean asychronously)
protected <T> List<T> batchUpdate(List<T> entities, WriteOptions options, boolean asychronously)
tableName
- entities
- optionsByName
- updateAsychronously
- protected <T> void delete(T entity, QueryOptions options, boolean asynchronously)
tableName
- entity
- protected <T> T update(T entity, WriteOptions options, boolean asychronously)
tableName
- entity
- optionsByName
- updateAsychronously
- public static com.datastax.driver.core.querybuilder.Insert createInsertQuery(String tableName, Object objectToSave, WriteOptions options, EntityWriter<Object,Object> entityWriter)
tableName
- objectToSave
- entity
- optionsByName
- public static com.datastax.driver.core.querybuilder.Update toUpdateQuery(String tableName, Object objectToSave, WriteOptions options, EntityWriter<Object,Object> entityWriter)
tableName
- objectToSave
- entity
- optionsByName
- public static <T> com.datastax.driver.core.querybuilder.Batch toUpdateBatchQuery(String tableName, List<T> objectsToSave, WriteOptions options, EntityWriter<Object,Object> entityWriter)
tableName
- objectsToSave
- entity
- optionsByName
- public static <T> com.datastax.driver.core.querybuilder.Batch createInsertBatchQuery(String tableName, List<T> entities, WriteOptions options, EntityWriter<Object,Object> entityWriter)
tableName
- entities
- entity
- optionsByName
- public static com.datastax.driver.core.querybuilder.Delete createDeleteQuery(String tableName, Object object, QueryOptions options, EntityWriter<Object,Object> entityWriter)
tableName
- object
- entity
- optionsByName
- public static <T> com.datastax.driver.core.querybuilder.Batch createDeleteBatchQuery(String tableName, List<T> entities, QueryOptions options, EntityWriter<Object,Object> entityWriter)
tableName
- entities
- entity
- optionsByName
- public <T> void deleteAll(Class<T> clazz)
CassandraOperations
deleteAll
in interface CassandraOperations
Copyright © 2011-2014–2014 Pivotal Software, Inc.. All rights reserved.