Package com.datastax.driver.core.querybuilder.Select

Examples of com.datastax.driver.core.querybuilder.Select.Selection


        return name;
    }

    public static Selection select(List<CassandraColumnHandle> columns)
    {
        Selection selection = QueryBuilder.select();
        for (CassandraColumnHandle column : columns) {
            selection.column(validColumnName(column.getName()));
        }
        return selection;
    }
View Full Code Here


        return name;
    }

    public static Selection select(List<CassandraColumnHandle> columns)
    {
        Selection selection = QueryBuilder.select();
        for (CassandraColumnHandle column : columns) {
            selection.column(validColumnName(column.getName()));
        }
        return selection;
    }
View Full Code Here

        return name;
    }

    public static Selection select(List<CassandraColumnHandle> columns)
    {
        Selection selection = QueryBuilder.select();
        for (CassandraColumnHandle column : columns) {
            selection.column(validColumnName(column.getName()));
        }
        return selection;
    }
View Full Code Here

        return name;
    }

    public static Selection select(List<CassandraColumnHandle> columns)
    {
        Selection selection = QueryBuilder.select();
        for (CassandraColumnHandle column : columns) {
            selection.column(validColumnName(column.getName()));
        }
        return selection;
    }
View Full Code Here

        PropertyMeta idMeta = entityMeta.getIdMeta();

        if (pm.structure().isCounter()) {
            throw new IllegalArgumentException(String.format("Cannot prepare statement for property '%s' of entity '%s' because it is a counter type",pm.getPropertyName(),entityMeta.getClassName()));
        } else {
            Selection select = pm.forStatementGeneration().prepareSelectField(select());
            final EntityMetaConfig metaConfig = entityMeta.config();
            Select from = select.from(metaConfig.getKeyspaceName(), metaConfig.getTableName());
            RegularStatement statement = idMeta.forStatementGeneration().generateWhereClauseForSelect(Optional.fromNullable(pm), from);
            return session.prepare(statement.getQueryString());
        }
    }
View Full Code Here

    public PreparedStatement prepareSelectAll(Session session, EntityMeta entityMeta) {
        log.trace("Generate prepared statement for SELECT of {}", entityMeta);

        PropertyMeta idMeta = entityMeta.getIdMeta();
        final EntityMetaConfig metaConfig = entityMeta.config();
        Selection select = select();

        for (PropertyMeta pm : entityMeta.forOperations().getColumnsMetaToLoad()) {
            select = pm.forStatementGeneration().prepareSelectField(select);
        }
        Select from = select.from(metaConfig.getKeyspaceName(), metaConfig.getTableName());

        Optional<PropertyMeta> staticMeta = Optional.absent();
        if (entityMeta.structure().hasOnlyStaticColumns()) {
            staticMeta = Optional.fromNullable(entityMeta.getAllMetasExceptId().get(0));
        }
View Full Code Here

        log.trace("Generate SELECT statement for slice query");

        EntityMeta entityMeta = sliceQueryProperties.getEntityMeta();
        final EntityMetaConfig metaConfig = entityMeta.config();

        Selection select = select();

        for (PropertyMeta pm : entityMeta.forOperations().getColumnsMetaToLoad()) {
            select = pm.forStatementGeneration().prepareSelectField(select);
        }

        Select from = select.from(metaConfig.getKeyspaceName(), metaConfig.getTableName());

        final RegularStatement whereClause = sliceQueryProperties.generateWhereClauseForSelect(from);

        return session.prepare(whereClause.getQueryString());
    }
View Full Code Here

    }

    @Test
    public void should_prepare_select_fields_for_embedded_id() throws Exception {
        //Given
        final Selection select = select();
        when(meta.structure().isEmbeddedId()).thenReturn(true);
        when(embeddedIdProperties.getCQL3ComponentNames()).thenReturn(asList("id", "name"));

        //When
        final Selection actual = view.prepareSelectField(select);

        //Then
        assertThat(actual.from("table").getQueryString()).isEqualTo("SELECT id,name FROM table;");
    }
View Full Code Here

    }

    @Test
    public void should_prepare_select_fields_for_id() throws Exception {
        //Given
        final Selection select = select();
        when(meta.structure().isEmbeddedId()).thenReturn(false);
        when(meta.getCQL3ColumnName()).thenReturn("id");

        //When
        final Selection actual = view.prepareSelectField(select);

        //Then
        assertThat(actual.from("table").getQueryString()).isEqualTo("SELECT id FROM table;");
    }
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.querybuilder.Select.Selection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.