Search in sources :

Example 21 with ColumnMetadata

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());
}
Also used : ColumnMetadata(com.datastax.driver.core.ColumnMetadata) BoundStatementMapper(org.simpleflatmapper.datastax.BoundStatementMapper)

Example 22 with ColumnMetadata

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());
}
Also used : ColumnMetadata(com.datastax.driver.core.ColumnMetadata) BoundStatementMapper(org.simpleflatmapper.datastax.BoundStatementMapper)

Example 23 with ColumnMetadata

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();
}
Also used : ColumnMetadata(com.datastax.driver.core.ColumnMetadata)

Example 24 with ColumnMetadata

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);
    }
}
Also used : ColumnMetadata(com.datastax.driver.core.ColumnMetadata) Column(org.teiid.metadata.Column)

Example 25 with ColumnMetadata

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);
}
Also used : ColumnMetadata(com.datastax.driver.core.ColumnMetadata) Test(org.testng.annotations.Test) CassandraVersion(com.datastax.driver.core.utils.CassandraVersion)

Aggregations

ColumnMetadata (com.datastax.driver.core.ColumnMetadata)37 Test (org.testng.annotations.Test)11 TableMetadata (com.datastax.driver.core.TableMetadata)8 CassandraVersion (com.datastax.driver.core.utils.CassandraVersion)8 EntityTypeMetadata (com.datastax.driver.mapping.meta.EntityTypeMetadata)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 AbstractTableMetadata (com.datastax.driver.core.AbstractTableMetadata)2 KeyspaceMetadata (com.datastax.driver.core.KeyspaceMetadata)2 ImmutableList (com.google.common.collect.ImmutableList)2 ByteBuffer (java.nio.ByteBuffer)2 BoundStatementMapper (org.simpleflatmapper.datastax.BoundStatementMapper)2 Cluster (com.datastax.driver.core.Cluster)1 DataType (com.datastax.driver.core.DataType)1 MaterializedViewMetadata (com.datastax.driver.core.MaterializedViewMetadata)1 RegularStatement (com.datastax.driver.core.RegularStatement)1 EntityWithCompositeKey (com.datastax.driver.mapping.entity.EntityWithCompositeKey)1 EntityWithIndexes (com.datastax.driver.mapping.entity.EntityWithIndexes)1 EntityWithTimeUUID (com.datastax.driver.mapping.entity.EntityWithTimeUUID)1 EntityFieldMetaData (com.datastax.driver.mapping.meta.EntityFieldMetaData)1