-
Notifications
You must be signed in to change notification settings - Fork 92
Schema Generator
Achilles provides a command-line schema generator as well as an class to generate CQL schema script.
First you need to compile your entity classes with Achilles and generate a .jar file. Then retrieve the achilles-schema-generator--shaded.jar file from your Maven repository.
In a shell, type:
java -cp <jar_containing_your_entity_classes>:achilles-schema-generator-<version>-shaded.jar info.archinnov.achilles.schema.SchemaGenerator -target <target_cql_script> -keyspace <keyspace_name>
The generator will scan your <jar_containing_your_entity_classes> file for the generated meta classes and generate the CQL schema into the <target_cql_script> file using the provided <keyspace_name>.
Please note that if the keyspace name is defined statically on the entity using
@Table
, it will override the given <keyspace_name>
You can also use the SchemaGenerator
in a project by pulling the Maven dependency
<dependency>
<groupId>info.archinnov</groupId>
<artifactId>achilles-schema-generator</artifactId>
<version>${achilles.version}</version>
</depepdency>
Usage:
// Create a schema String
String cqlSchema = SchemaGenerator.builder()
.withKeyspace("default_keyspace_name")
.generateCustomTypes(true) //default = true
.generateIndices(true) //default = true
.generate();
/**
*
* Generate to an instance of java.lang.Appendable
*
*/
SchemaGenerator.builder()
.withKeyspace("default_keyspace_name")
.generateCustomTypes(true) //default = true
.generateIndices(true) //default = true
.generateTo(appendable);
/**
*
* Generate to an instance of java.io.File
*
*/
SchemaGenerator.builder()
.withKeyspace("default_keyspace_name")
.generateCustomTypes(true) //default = true
.generateIndices(true) //default = true
.generateTo(file);
/**
*
* Generate to an instance of java.nio.file.Path
*
*/
SchemaGenerator.builder()
.withKeyspace("default_keyspace_name")
.generateCustomTypes(true) //default = true
.generateIndices(true) //default = true
.generateTo(path);
-
Bootstraping Achilles at runtime
- Runtime Configuration Parameters
-
Manager
-
Consistency Level
-
Cassandra Options at runtime
-
Lightweight Transaction (LWT)
-
JSON Serialization
-
Interceptors
-
Bean Validation (JSR-303)