use of com.datastax.driver.core.ColumnMetadata in project SimpleFlatMapper by arnaudroger.
the class DatastaxCrudFactory method keySetter.
private static <K> BoundStatementMapper<K> keySetter(Type keyTarget, TableMetadata tableMetadata, DatastaxMapperFactory mapperFactory, int offset) {
SettableDataMapperBuilder<K> mapperBuilder = mapperFactory.newBuilderFrom(keyTarget);
int i = offset;
for (ColumnMetadata columnMetadata : tableMetadata.getPrimaryKey()) {
mapperBuilder.addColumn(DatastaxColumnKey.of(columnMetadata, i++));
}
return new BoundStatementMapper<K>(mapperBuilder.mapper());
}
use of com.datastax.driver.core.ColumnMetadata in project SimpleFlatMapper by arnaudroger.
the class DatastaxCrudFactory method insertSetter.
private static <T> BoundStatementMapper<T> insertSetter(Type target, TableMetadata tableMetadata, DatastaxMapperFactory mapperFactory, int offset) {
SettableDataMapperBuilder<T> mapperBuilder = mapperFactory.newBuilderFrom(target);
int i = offset;
for (ColumnMetadata columnMetadata : tableMetadata.getColumns()) {
mapperBuilder.addColumn(DatastaxColumnKey.of(columnMetadata, i++));
}
return new BoundStatementMapper<T>(mapperBuilder.mapper());
}
use of com.datastax.driver.core.ColumnMetadata in project SimpleFlatMapper by arnaudroger.
the class DatastaxCrudFactory method deleteQuery.
private static String deleteQuery(TableMetadata tableMetadata) {
Delete delete = QueryBuilder.delete().from(tableMetadata);
Delete.Where where = delete.where();
List<ColumnMetadata> columns = tableMetadata.getPrimaryKey();
for (ColumnMetadata column : columns) {
where.and(QueryBuilder.eq(column.getName(), QueryBuilder.bindMarker()));
}
return delete.toString();
}
use of com.datastax.driver.core.ColumnMetadata in project teiid by teiid.
the class CassandraMetadataProcessor method addColumnsToTable.
/**
* Adds all columns of column family.
* @param table Teiid table
* @param columnFamily Column family
*/
private void addColumnsToTable(MetadataFactory factory, Table table, TableMetadata columnFamily) {
for (ColumnMetadata column : columnFamily.getColumns()) {
String type = asTeiidRuntimeType(column.getType().getName());
Column c = factory.addColumn(column.getName(), type, table);
c.setUpdatable(true);
c.setSearchType(SearchType.Unsearchable);
}
}
use of com.datastax.driver.core.ColumnMetadata in project java-driver by datastax.
the class IndexMetadataTest method should_create_metadata_for_index_on_map_keys.
@Test(groups = "short")
@CassandraVersion("2.1.0")
public void should_create_metadata_for_index_on_map_keys() {
String createKeysIndex = String.format("CREATE INDEX map_keys_index ON %s.indexing (keys(map_keys));", keyspace);
session().execute(createKeysIndex);
ColumnMetadata column = getColumn("map_keys");
IndexMetadata index = getIndex("map_keys_index");
assertThat(index).hasName("map_keys_index").hasParent((TableMetadata) column.getParent()).isNotCustomIndex().hasTarget("keys(map_keys)").hasKind(COMPOSITES).asCqlQuery(createKeysIndex);
assertThat((TableMetadata) column.getParent()).hasIndex(index);
}
Aggregations