If you are migrating from Achilles 3.x to Achilles 4.x, below are the changes and how to transition:
@Entity: renamed to @Table@CompoundPrimaryKey: removed, now you can use directly @PartitionKey and @ClusteringColumn in the entity@TypeTransformer: removed, use @Codec or @RuntimeCodec instead. See Codec System for more detailsCounter: removed, use @Counter annotation on a Long field insteadCounterBuilder: removed. Now use the DSL API to increment/decrement countersOptions and OptionsBuilder: removed. Now all options are exposed as methods in CRUD API and DSL APIIndexCondition: removed. Will be replace by a Index API laterAchillesFuture<T>: removed and replaced by CompletableFuture<T>EntityWithPagingState<T>: removed, replaced by com.datastax.driver.core.ExecutionInfoTypedMapsWithPagingState: removed.The feature has been removed because it added more complexity. The flexible DSL API can cover most of related
use-cases
The old PersistenceManager is now replaced by compile-time generated Manager
insert(...): replaced by crud().insert(...)update(...): removed. Feature covered by dsl().update()forUpdate(...): removed. Feature covered by dsl().update()delete(...): replaced by crud().delete(...)deleteById(...): replaced by crud().deleteById(...) and crud.deleteByPartitionKeys(...)find(...): replaced by crud().findById(...)initialize(...): removed. No more needed because proxy is no longer supportedremoveProxy(...): removed. No more needed because proxy is no longer supportedinitAndRemoveProxy(...): removed. No more needed because proxy is no longer supportedserializeToJson(...): removed. If needed, use XXX_AchillesMeta.The Slice Query API is replaced by the DSL API
The Typed Query API is replaced by query().typeQueryForSelect(...). See RAW API
The Native Query API is replaced by query().nativeQuery(...). See RAW API
The Indexed Query API has been removed and will be replaced by a indexQuery() API later
All the Counter API and related methods have been removed. Now just use dsl().update() to handle
counter increment/decrement. Counter deletion is achieved using crud().deleteById() orcrud().deleteByPartitionKeys() for static counters
The @Consistency annotation can now only be used on a class. Runtime ad-hoc consistency level setting is handled
by the appropriate method for each existing API
Options at runtime are now handled seamlessly by the appropriate methods for each existing API.
LightWeight Transaction operations are handled seamlessly by the appropriate methods (ifNotExists(),
ifExists(), if_XXX_Eq(..) ...) on each existing API
The Batch mode has been removed. Now Achilles relies on native Java driver BatchStatement to handle
batches
This feature is no longer supported. Schema changes are sensitive operations in production and should be handled
by human operator, not automatically by a software.
Achilles 3.x:
Cluster cluster = Cluster.builder()....build();
PersistenceManagerFactory persistenceManagerFactory = PersistenceManagerFactoryBuilder
.builder(cluster)
.withEntityPackages("my.package1,my.package2")
.withConnectionContactPoints("localhost")
.withCQLPort(9041)
.withKeyspaceName("Test Keyspace")
.forceTableCreation(true).build();
Achilles 4.x:
Cluster cluster = Cluster.builder()....build();
ManagerFactory managerFactory = ManagerFactoryBuilder
.builder(cluster)
.withDefaultKeyspaceName("Test Keyspace")
.forceTableCreation(true)
.build();
User_Manager manager = managerFactory.forUser();
The old JUnit bootstrap has been changed:
Achilles 3.x:
@Rule
public AchillesResource resource = AchillesResourceBuilder
.withEntityPackages("com.project.entity")
.withKeyspaceName("myKeyspace")
.tablesToTruncate("table1","anotherTable")
.build();
Achilles 4.x:
@Rule
public AchillesTestResource resource = AchillesTestResourceBuilder
.forJunit()
.withScript("script1.cql")
.withScript("script2.cql")
.tablesToTruncate("users", "tweet_lines") // entityClassesToTruncate(User.class, TweetLine.class)
.createAndUseKeyspace("unit_test")
.
...
.build((cluster, statementsCache) -> ManagerFactoryBuilder
.builder(cluster)
.doForceSchemaCreation(true)
.withStatementCache(statementsCache) //MANDATORY
.withDefaultKeyspaceName("achilles_embedded")
.build()
);