Search in sources :

Example 1 with EntityWithCompositeKey

use of com.datastax.driver.mapping.entity.EntityWithCompositeKey in project cassandra-driver-mapping by valchkou.

the class MappingSessionAsyncTest method saveAndGetAndDeleteWithCompoundCompositeKeyTest.

@Test
public void saveAndGetAndDeleteWithCompoundCompositeKeyTest() throws Exception {
    SimpleKey partition = new SimpleKey();
    partition.setName("name");
    partition.setRank(10);
    partition.setT1(UUIDs.timeBased());
    partition.setT2(UUIDs.timeBased());
    CompositeKey key = new CompositeKey();
    key.setKey(partition);
    Date created = new Date();
    key.setCreated(created);
    key.setEmail("email@at");
    EntityWithCompositeKey obj = new EntityWithCompositeKey();
    obj.setKey(key);
    obj.setTimestamp(1000);
    obj.setAsof(created);
    EntityWithCompositeKey loaded = target.get(EntityWithCompositeKey.class, key);
    assertNull(loaded);
    ResultSetFuture f = target.saveAsync(obj);
    f.getUninterruptibly();
    loaded = target.get(EntityWithCompositeKey.class, key);
    assertEquals(obj, loaded);
    f = target.deleteAsync(loaded);
    f.getUninterruptibly();
    loaded = target.get(EntityWithCompositeKey.class, key);
    assertNull(loaded);
}
Also used : CompositeKey(com.datastax.driver.mapping.entity.CompositeKey) EntityWithCompositeKey(com.datastax.driver.mapping.entity.EntityWithCompositeKey) ResultSetFuture(com.datastax.driver.core.ResultSetFuture) EntityWithCompositeKey(com.datastax.driver.mapping.entity.EntityWithCompositeKey) Date(java.util.Date) SimpleKey(com.datastax.driver.mapping.entity.SimpleKey) Test(org.junit.Test)

Aggregations

ResultSetFuture (com.datastax.driver.core.ResultSetFuture)1 CompositeKey (com.datastax.driver.mapping.entity.CompositeKey)1 EntityWithCompositeKey (com.datastax.driver.mapping.entity.EntityWithCompositeKey)1 SimpleKey (com.datastax.driver.mapping.entity.SimpleKey)1 Date (java.util.Date)1 Test (org.junit.Test)1