Using compile-time code generation through Annotation Processor, Achilles can
For each entity class annotated with @Table, Achilles will generate a correspondinginfo.archinnov.achilles.generated.meta.entity.<entity_class_name>_AchillesMeta class
This meta class exposes the following useful methods:
public T createEntityFrom(Row row): self-explanatorypublic ConsistencyLevel readConsistency(Optional<ConsistencyLevel> runtimeConsistency): retrieve read consistency frompublic ConsistencyLevel writeConsistency(Optional<ConsistencyLevel> runtimeConsistency): retrieve write consistency frompublic ConsistencyLevel serialConsistency(Optional<ConsistencyLevel> runtimeConsistency): retrieve serial consistency frompublic InsertStrategy insertStrategy(): determine insert strategy using static annotation and Achilles globalpublic void triggerInterceptorsForEvent(Event event, T instance) : trigger all registered interceptors for this entityEach meta class contains a public static field for each property. For example, given the following entity:
@Table
public static User {
@PartitionKey
private Long userId;
@Column
private String firstname;
@Column
private String lastname;
@Column
private Set<String> favoriteTags;
...
}
The User_AchillesMeta class will expose the following static property meta:
User_AchillesMeta.userIdUser_AchillesMeta.firstnameUser_AchillesMeta.lastnameUser_AchillesMeta.favoriteTagsEach property meta class will expose:
public VALUETO encodeFromJava(VALUEFROM javaValue, Optional<CassandraOptions> options): encode the given Java value into CQL-compatible value using the Codec System. You can pass a CassandraOptions instance containing a SchemaNameProvider for dynamic schema. Use the method CassandraOptions.withSchemaNameProvider(SchemaNameProvider provider) to create an instance of this classpublic VALUEFROM decodeFromGettable(GettableData gettableData): decode the value of the current property from the GettableData object.GettableData is the common interface for com.datastax.driver.core.Row, com.datastax.driver.core.UDTValuecom.datastax.driver.core.TupleValueFor type-safe function call (from Cassandra_2_2_X and after), Achilles also generates a COLUMNS field inside the info.archinnov.achilles.generated.meta.entity.<entity_class_name>_AchillesMeta class. This field will expose all the entity fields with the correct mirror type useful for type-safe function calls.
For more details, see Functions Mapping
In addition to meta classes, Achilles also generates for each entity a
info.archinnov.achilles.generated.manager.<entity_class_name>_Manager class that exposes the following methods:
crud(): exposes the CRUD APIdsl(): exposes the DSL APIindex(): exposes the Indexed APIraw(): exposes the RAW APITo be type-safe, Achilles also generates one info.archinnov.achilles.generated.ManagerFactory class
that exposes as many public <entity_class_name>_Manager for<entity_class_name>() methods as there are
different entity classes.
Please note that all entity classes and related UDT classes should be in the same compilation unit, e.g. the source
code of all entity classes and related UDT classes should be compiled together in one go.
If your project import some external entity classes shipped in a .jar file, Achilles does not have access to its
source code, thus cannot generate all the meta and manager classes for those entities.
Read multi-project support if you need this feature