-
Notifications
You must be signed in to change notification settings - Fork 92
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:
-
@Entity
: renamed to@Table
-
@CompoundPrimaryKey
: removed, now you can use directly@PartitionKey
and@ClusteringColumn
in the entity without having to declare a separated class for the compound primary key -
@TypeTransformer
: removed, use@Codec
or@RuntimeCodec
instead. See Codec System for more details
-
Counter
: removed, use@Counter
annotation on aLong
field instead -
CounterBuilder
: removed. Now use the DSL API to increment/decrement counters -
Options
andOptionsBuilder
: removed. Now all options are exposed as methods in CRUD API and DSL API -
IndexCondition
: removed. Will be replace by a Index API later -
AchillesFuture<T>
: removed and replaced byCompletableFuture<T>
-
EntityWithPagingState<T>
: removed, replaced bycom.datastax.driver.core.ExecutionInfo
-
TypedMapsWithPagingState
: 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 where X is the entity class
-
insert(...)
: replaced bycrud().insert(...)
-
update(...)
: removed. Feature covered bydsl().update()
-
forUpdate(...)
: removed. Feature covered bydsl().update()
-
delete(...)
: replaced bycrud().delete(...)
-
deleteById(...)
: replaced bycrud().deleteById(...)
andcrud.deleteByPartitionKeys(...)
-
find(...)
: replaced bycrud().findById(...)
-
initialize(...)
: removed. No more needed because proxy is no longer supported -
removeProxy(...)
: removed. No more needed because proxy is no longer supported -
initAndRemoveProxy(...)
: removed. No more needed because proxy is no longer supported -
serializeToJson(...)
: removed. If needed, use XXX_AchillesMeta..encode()
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()
or
crud().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()
);
-
Bootstraping Achilles at runtime
- Runtime Configuration Parameters
-
Manager
-
Consistency Level
-
Cassandra Options at runtime
-
Lightweight Transaction (LWT)
-
JSON Serialization
-
Interceptors
-
Bean Validation (JSR-303)