Compile-Time-Config

When using Achilles you should be aware of the fact that the framework invoked at compile time and at runtime.

At compile time Achilles will parse your source code to generate additional source code. To configure Achilles at compile time, you can use the @CompileTimeConfig annotation on a class or an interface

The interface/class can (and should) be empty. What interests us here is the attributes set on the annotation


    @CompileTimeConfig(cassandraVersion = CassandraVersion.CASSANDRA_3_0_X, 
                        columnMappingStrategy = ColumnMappingStrategy.IMPLICIT,
                        namingStrategy = NamingStrategy.SNAKE_CASE,
                        insertStrategy = InsertStrategy.ALL_FIELDS,
                        projectName = "Project1" 
    public interface AchillesCompileTimeConfig {
    
    }

What you can specify as configuration at compile time are:

Please refer to the appropriate section for each of those parameters.

Specifying the Cassandra version will help Achilles unlock and generate new features that are only supported by this version and after.

For example, materialized views are not available before CassandraVersion.CASSANDRA_3_0_X

Below is the Cassandra version feature matrix:

Cassandra version Supported features Related JIRA(s)
2.1.X All existing features N/A
2.2.X
  • JSON Syntax
  • User Defined Functions
  • User Defined Aggregates
  • CASSANDRA-7970
  • CASSANDRA-7395, CASSANDRA-7526, CASSANDRA-7562, CASSANDRA-7740, CASSANDRA-7781, CASSANDRA-7929, CASSANDRA-7924, CASSANDRA-7812, CASSANDRA-8063, CASSANDRA-7813, CASSANDRA-7708
  • CASSANDRA-8053
3.0.X
  • Materialized Views
  • Support for IN restrictions on any partition key component or clustering key as well as support for EQ and IN multicolumn restrictions has been added to UPDATE and DELETE statement
  • Support for single-column and multi-column slice restrictions (>, >=, <= and <) has been added to DELETE statements
  • CASSANDRA-6477
3.1 Nothing N/A
3.2 Add support for type casting in selection clause CASSANDRA-10310

And below is the impact of each new feature on Achilles-generated code:

Cassandra Feature Achilles generated code
JSON Syntax
  • manager.crud().insertJson(String json)
  • manager.dsl().....where().xxx().Eq_FromJSON()
  • manager.dsl().select().allColumnsAsJSON_FromBaseTable().....where()......getJSON()
  • manager.dsl().update().....xxx().Set_FromJSON()
  • manager.dsl().update().....if_xxx().Eq_FromJSON()
  • manager.dsl().delete().....if_xxx().Eq_FromJSON()
User Defined Function/User Defined Aggregates
  • @FunctionRegistry is allowed
  • info.archinnov.achilles.generated.function.FunctionsRegistry generated class
Materialized Views
  • @MaterializedView is allowed
Support for IN restrictions on clustering columns for UPDATE/DELETE
  • manager.dsl().update()...where()....xxx().IN(...)
  • manager.dsl().delete()...where()....xxx().IN(...)
Support for multi-column slice restrictions (>, >=, <= and <) for DELETE
  • manager.dsl().delete()...where()....xxx().Gt(...)
  • manager.dsl().delete()...where()....xxx().Gt_And_Lt(...)
Support for type casting in selection clause
  • manager.dsl().select().function(SystemFunctions.castAsxxx()...)

Last but not least, the projectName() attribute is crucial for those who are using Achilles for multiple projects.

For more details see Multi-Project support