managedEntityFuture = asyncManager.insert(myEntity); II Update asynchronously for modifications
User managedUser = asyncManager.find(User.class,1L).get(); user.setFirstname("DuyHai"); AchillesFuture userFuture = asyncManager.update(user);
III Removing asynchronously entities
// Simple removed User managedUser = asyncManager.find(User.class,1L).get(); AchillesFuture userFuture = asyncManager.remove(managedUser); // Direct remove without read-before-write AchillesFuture emptyFuture = asyncManager.removeById(User.class,1L);
IV Loading entities asynchronously
// Read data from Cassandra AchillesFuture managedUserFuture = asyncManager.find(User.class,1L);
V Creating proxy for update
Please note that proxy creation always return immediately since we do not hit the database // No data read from Cassandra User managedUserProxy = asyncManager.getProxy(User.class,1L).get(); managedUser.setAge(30); // Direct update, no read from Cassandra has been done AchillesFuture userFuture = asyncManager.update(managedUser);
VI Reloading state asynchronously for managed entities
// Read data from Cassandra User managedUser = asyncManager.find(User.class,1L).get(); ... // Perform some logic // Reload data from Cassandra into the managed entity AchillesFuture userFuture = asyncManager.refresh(managedUser);
VII Initializing lazy fields for managed entity
// Create a proxy User managedUser = asyncManager.getProxy(User.class,1L).get(); ... // Perform some logic // Initialize all fields not yet loaded into the managed entity, including counter fields asyncManager.initialize(managedUser);
VIII Removing proxy from managed entities
// Create proxy User managedUser = asyncManager.getProxy(User.class,1L); ... // Perform some logic // Removing proxy before passing it to client via serialization User transientUser = asyncManager.removeProxy(managedUser);
IX Accessing native Session object
Session session = asyncManager.getNativeSession(); ... // Issue simple CQL3 queries session.execute("UPDATE users SET age=:age WHERE id=:id",30,10);
X JSON serialization/deserialization
// Serialize an object to JSON using the registered or default object mapper String json = asyncManager.serializeToJSON(myModel); ... // Deserialize a JSON string into an object the registered or default object mapper MyModel myModel = asyncManager.deserializeFromJSON(json);
XI Initializing all lazy fields
// Create proxy User userProxy = asyncManager.getProxy(User.class,1L); ... // Perform some logic ... // Load all other lazy fields asyncManager.initialize(userProxy);
@see Persistence Manager operations