use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class SchemaSync method sync.
public static synchronized void sync(String keyspace, Session session, Class<?> clazz, SyncOptions syncOptions) {
EntityTypeMetadata entityMetadata = EntityTypeParser.getEntityMetadata(clazz);
if (entityMetadata.isSynced(keyspace))
return;
List<RegularStatement> statements = buildSyncStatements(keyspace, session, entityMetadata, syncOptions);
for (RegularStatement stmt : statements) {
session.execute(stmt);
}
entityMetadata.markSynced(keyspace);
}
use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class EntityTypeParserTest method testGetEntityMetadataForSimpleCompoundKey.
@Test
public void testGetEntityMetadataForSimpleCompoundKey() {
EntityTypeMetadata meta = EntityTypeParser.getEntityMetadata(EntityWithKey.class);
assertEquals("test_entity", meta.getTableName());
assertEquals(0, meta.getIndexes().size());
assertEquals(6, meta.getFields().size());
PrimaryKeyMetadata pkm = meta.getPrimaryKeyMetadata();
assertNotNull(pkm);
assertTrue(pkm.isCompound());
assertFalse(pkm.hasPartitionKey());
}
use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class EntityTypeParserTest method testGetEntityMetadataWithTtl.
@Test
public void testGetEntityMetadataWithTtl() {
EntityTypeMetadata meta = EntityTypeParser.getEntityMetadata(EntityWithTtl.class);
assertEquals("test_entity_ttl", meta.getTableName());
assertEquals(0, meta.getIndexes().size());
assertEquals(3, meta.getFields().size());
assertEquals(3, meta.getTtl());
}
use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class EntityTypeParserTest method testGetEntityMetadataOverrideCollectionType.
@Test
public void testGetEntityMetadataOverrideCollectionType() {
EntityTypeMetadata meta = EntityTypeParser.getEntityMetadata(EntityWithCollectionsOverride.class);
assertEquals(4, meta.getFields().size());
EntityFieldMetaData fd = meta.getFieldMetadata("rates");
assertEquals(TreeMap.class, fd.getCollectionType());
fd = meta.getFieldMetadata("refs");
assertEquals(TreeSet.class, fd.getCollectionType());
fd = meta.getFieldMetadata("trades");
assertEquals(LinkedList.class, fd.getCollectionType());
}
use of com.datastax.driver.mapping.meta.EntityTypeMetadata in project cassandra-driver-mapping by valchkou.
the class EntityTypeParserTest method testGetKeyDataIdKey.
@Test
public void testGetKeyDataIdKey() {
EntityTypeMetadata meta = EntityTypeParser.getEntityMetadata(Simple.class);
List<String> cols = meta.getPkColumns();
assertEquals(1, cols.size());
assertEquals("id", cols.get(0));
UUID id = UUID.randomUUID();
List<Object> vals = meta.getIdValues(id);
assertEquals(1, vals.size());
assertEquals(id, vals.get(0));
}
Aggregations