Class StatementFactory
java.lang.Object
org.springframework.data.cassandra.core.StatementFactory
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfaceStrategy interface to computecolumn projectionto be selected for a query based on a givenEntityProjection. -
Constructor Summary
ConstructorsConstructorDescriptionStatementFactory(CassandraConverter converter) CreateStatementFactorygivenCassandraConverter.StatementFactory(QueryMapper queryMapper, UpdateMapper updateMapper) StatementFactory(UpdateMapper updateMapper) CreateStatementFactorygivenUpdateMapper. -
Method Summary
Modifier and TypeMethodDescriptionStatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> count(Query query, CassandraPersistentEntity<?> entity) Create a COUNT statement by mappingQuerytoSelect.StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> count(Query query, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create a COUNT statement by mappingQuerytoSelect.StatementBuilder<com.datastax.oss.driver.api.querybuilder.delete.Delete> delete(Object entity, QueryOptions options, EntityWriter<Object, Object> entityWriter, com.datastax.oss.driver.api.core.CqlIdentifier tableName) StatementBuilder<com.datastax.oss.driver.api.querybuilder.delete.Delete> delete(Query query, CassandraPersistentEntity<?> entity) Create a DELETE statement by mappingQuerytoDelete.StatementBuilder<com.datastax.oss.driver.api.querybuilder.delete.Delete> delete(Query query, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create a DELETE statement by mappingQuerytoDelete.StatementBuilder<com.datastax.oss.driver.api.querybuilder.delete.Delete> deleteById(Object id, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create an DELETE statement by mappingidto SELECT … WHERE consideringUpdateOptions.protected QueryMapperReturn theQueryMapperused to mapQueryto CQL-specific data types.protected UpdateMapperReturn theUpdateMapperused to mapUpdateto CQL-specific data types.StatementBuilder<com.datastax.oss.driver.api.querybuilder.insert.RegularInsert> insert(Object objectToInsert, WriteOptions options) Creates a Query Object for an insert.StatementBuilder<com.datastax.oss.driver.api.querybuilder.insert.RegularInsert> insert(Object objectToInsert, WriteOptions options, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Creates a Query Object for an insert.StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> select(Query query, CassandraPersistentEntity<?> entity) Create a SELECT statement by mappingQuerytoSelect.StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> select(Query query, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create a SELECT statement by mappingQuerytoSelect.StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> select(Query query, EntityProjection<?, ?> projection, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create a SELECT statement by mappingQuerytoSelectconsidering projections.StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> selectExists(Object id, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create an SELECT statement by mappingidto SELECT … WHERE.StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> selectExists(Query query, EntityProjection<?, ?> projection, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create a SELECT statement by mappingQuerytoSelectto run an exists query limiting results to one.StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> selectOneById(Object id, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create an SELECT statement by mappingidto SELECT … WHERE.voidsetKeyspaceProvider(StatementFactory.KeyspaceProvider keyspaceProvider) voidsetProjectionFunction(StatementFactory.ProjectionFunction projectionFunction) Set the defaultStatementFactory.ProjectionFunctionto determineColumnsfor aSelectstatement if the query did not specify any columns.StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update(Object objectToUpdate, WriteOptions options) StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update(Object objectToUpdate, WriteOptions options, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update(Query query, Update update, CassandraPersistentEntity<?> entity)
-
Constructor Details
-
StatementFactory
CreateStatementFactorygivenCassandraConverter.- Parameters:
converter- must not be null.- Since:
- 3.0
-
StatementFactory
CreateStatementFactorygivenUpdateMapper.- Parameters:
updateMapper- must not be null.
-
StatementFactory
- Parameters:
queryMapper- must not be null.updateMapper- must not be null.
-
-
Method Details
-
getQueryMapper
Return theQueryMapperused to mapQueryto CQL-specific data types.- Returns:
- the
QueryMapperused to mapQueryto CQL-specific data types. - See Also:
-
getUpdateMapper
Return theUpdateMapperused to mapUpdateto CQL-specific data types.- Returns:
- the
UpdateMapperused to mapUpdateto CQL-specific data types. - See Also:
-
setKeyspaceProvider
- Parameters:
keyspaceProvider- the keyspace provider to use, must not be null.- Since:
- 4.4
-
getProjectionFunction
- Returns:
- the configured projection function.
- Since:
- 5.0
-
setProjectionFunction
Set the defaultStatementFactory.ProjectionFunctionto determineColumnsfor aSelectstatement if the query did not specify any columns.- Parameters:
projectionFunction- the projection function to use, must not be null.- Since:
- 5.0
-
count
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> count(Query query, CassandraPersistentEntity<?> entity) Create a COUNT statement by mappingQuerytoSelect. -
count
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> count(Query query, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create a COUNT statement by mappingQuerytoSelect. -
selectExists
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> selectExists(Query query, EntityProjection<?, ?> projection, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create a SELECT statement by mappingQuerytoSelectto run an exists query limiting results to one.- Parameters:
query- must not be null.projection- must not be null.entity- must not be null.tableName- must not be null.- Returns:
- the select builder.
- Since:
- 5.0
-
selectExists
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> selectExists(Object id, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create an SELECT statement by mappingidto SELECT … WHERE. This method supports composite primary keys as part of the entity class itself or as separate primary key class.- Parameters:
id- must not be null.entity- must not be null.tableName- must not be null.- Returns:
- the select builder.
-
selectOneById
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> selectOneById(Object id, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create an SELECT statement by mappingidto SELECT … WHERE. This method supports composite primary keys as part of the entity class itself or as separate primary key class.- Parameters:
id- must not be null.entity- must not be null.tableName- must not be null.- Returns:
- the select builder.
-
select
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> select(Query query, CassandraPersistentEntity<?> entity) Create a SELECT statement by mappingQuerytoSelect.- Parameters:
query- must not be null.entity- must not be null.- Returns:
- the select builder.
-
select
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> select(Query query, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create a SELECT statement by mappingQuerytoSelect.- Parameters:
query- must not be null.entity- must not be null.tableName- must not be null.- Returns:
- the select builder.
- Since:
- 2.1
-
select
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.select.Select> select(Query query, EntityProjection<?, ?> projection, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create a SELECT statement by mappingQuerytoSelectconsidering projections.- Parameters:
query- must not be null.projection- must not be null.entity- must not be null.tableName- must not be null.- Returns:
- the select builder.
- Since:
- 5.0
-
insert
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.insert.RegularInsert> insert(Object objectToInsert, WriteOptions options) Creates a Query Object for an insert.- Parameters:
objectToInsert- the object to save, must not be null.options- optionalWriteOptionsto apply to theInsertstatement, may be null.- Returns:
- the select builder.
- Since:
- 3.0
-
insert
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.insert.RegularInsert> insert(Object objectToInsert, WriteOptions options, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Creates a Query Object for an insert.- Parameters:
objectToInsert- the object to save, must not be null.options- optionalWriteOptionsto apply to theInsertstatement, may be null.entity- theCassandraPersistentEntityto write insert values.tableName- the table name, must not be empty and not null.- Returns:
- the select builder.
-
update
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update(Query query, Update update, CassandraPersistentEntity<?> entity) - Parameters:
query- must not be null.entity- must not be null.- Returns:
- the update builder.
-
update
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update(Object objectToUpdate, WriteOptions options) - Parameters:
objectToUpdate- must not be null.options- must not be null.- Returns:
- the update builder.
- Since:
- 3.0
-
update
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.update.Update> update(Object objectToUpdate, WriteOptions options, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) - Parameters:
objectToUpdate- must not be null.options- must not be null.entity- must not be null.tableName- must not be null.- Returns:
- the update builder.
-
deleteById
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.delete.Delete> deleteById(Object id, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create an DELETE statement by mappingidto SELECT … WHERE consideringUpdateOptions.- Parameters:
id- must not be null.entity- must not be null.tableName- must not be null.- Returns:
- the delete builder.
-
delete
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.delete.Delete> delete(Query query, CassandraPersistentEntity<?> entity) Create a DELETE statement by mappingQuerytoDelete.- Parameters:
query- must not be null.entity- must not be null.- Returns:
- the delete builder.
-
delete
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.delete.Delete> delete(Query query, CassandraPersistentEntity<?> entity, com.datastax.oss.driver.api.core.CqlIdentifier tableName) Create a DELETE statement by mappingQuerytoDelete.- Parameters:
query- must not be null.entity- must not be null.tableName- must not be null.- Returns:
- the delete builder.
-
delete
public StatementBuilder<com.datastax.oss.driver.api.querybuilder.delete.Delete> delete(Object entity, QueryOptions options, EntityWriter<Object, Object> entityWriter, com.datastax.oss.driver.api.core.CqlIdentifier tableName) - Parameters:
entity- must not be null.options- must not be null.entityWriter- must not be null.tableName- must not be null.- Returns:
- the delete builder.
-