Class StatementFactory

java.lang.Object
org.springframework.data.cassandra.core.StatementFactory

public class StatementFactory extends Object
Factory to render Statement objects from Query and Update objects.
Since:
2.0
Author:
Mark Paluch, John Blum, Sam Lightfoot
See Also:
  • Constructor Details

  • Method Details

    • getQueryMapper

      protected QueryMapper getQueryMapper()
      Return the QueryMapper used to map Query to CQL-specific data types.
      Returns:
      the QueryMapper used to map Query to CQL-specific data types.
      See Also:
    • getUpdateMapper

      protected UpdateMapper getUpdateMapper()
      Return the UpdateMapper used to map Update to CQL-specific data types.
      Returns:
      the UpdateMapper used to map Update to CQL-specific data types.
      See Also:
    • setKeyspaceProvider

      public void setKeyspaceProvider(StatementFactory.KeyspaceProvider keyspaceProvider)
      Set the StatementFactory.KeyspaceProvider to determine the keyspace for a entity-related statement.
      Parameters:
      keyspaceProvider - the keyspace provider to use, must not be null.
      Since:
      4.4
    • getProjectionFunction

      public StatementFactory.ProjectionFunction getProjectionFunction()
      Returns:
      the configured projection function.
      Since:
      5.0
    • setProjectionFunction

      public void setProjectionFunction(StatementFactory.ProjectionFunction projectionFunction)
      Set the default StatementFactory.ProjectionFunction to determine Columns for a Select statement 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 mapping Query to Select.
      Parameters:
      query - user-defined count Query to execute; must not be null.
      entity - entity to count; must not be null.
      Returns:
      the select builder.
      Since:
      2.1
    • 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 mapping Query to Select.
      Parameters:
      query - user-defined count Query to execute; must not be null.
      entity - entity to count; must not be null.
      tableName - must not be null.
      Returns:
      the select builder.
      Since:
      2.1
    • 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 mapping Query to Select to 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 mapping id to 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 mapping id to 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 mapping Query to Select.
      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 mapping Query to Select.
      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 mapping Query to Select considering 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 - optional WriteOptions to apply to the Insert statement, 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 - optional WriteOptions to apply to the Insert statement, may be null.
      entity - the CassandraPersistentEntity to 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)
      Create an UPDATE statement by mapping Query to Update.
      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)
      Create an UPDATE statement by mapping objectToUpdate to Update considering UpdateOptions.
      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)
      Create an UPDATE statement by mapping objectToUpdate to Update considering UpdateOptions.
      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 mapping id to SELECT … WHERE considering UpdateOptions.
      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 mapping Query to Delete.
      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 mapping Query to Delete.
      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)
      Create an DELETE statement by mapping entity to DELETE … WHERE considering WriteOptions.
      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.