Migration-Guide-3-to-4

If you are migrating from Achilles 3.x to Achilles 4.x, below are the changes and how to transition:

Annotation Changes

Custom Types Changes

Dirty Checking And Proxy

The feature has been removed because it added more complexity. The flexible DSL API can cover most of related
use-cases

PersistenceManager

The old PersistenceManager is now replaced by compile-time generated Manager where X is the entity class

PersistenceManager API

Slice Query API

The Slice Query API is replaced by the DSL API

Query 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

Counter API

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() or
crud().deleteByPartitionKeys() for static counters

Consistency Level

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

Runtime Options

Options at runtime are now handled seamlessly by the appropriate methods for each existing API.

LightWeight Transaction

LightWeight Transaction operations are handled seamlessly by the appropriate methods (ifNotExists(),
ifExists(), if_XXX_Eq(..) ...) on each existing API

Batch Support

The Batch mode has been removed. Now Achilles relies on native Java driver BatchStatement to handle
batches

Dynamic Schema Update

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.

Bootstrapping

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();
    

JUnit Support

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()
        );