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

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


    }
    return selectWhere;
  }

    public static Where createRowQueryFromValues(List<byte[]> values, DboColumnMeta colMeta, Select selectQuery, String rowKey) {
        Where selectWhere = selectQuery.where();

        Clause rkClause = QueryBuilder.eq("id", rowKey);
        selectWhere.and(rkClause);

        Object[] valStrings = new Object[values.size()];
        int count = 0;
        for (byte[] value : values) {
            valStrings[count] = StandardConverters.convertFromBytes(String.class, value);
            count++;
        }
       
        Clause inClause = QueryBuilder.in("colname", valStrings);
        selectWhere.and(inClause);
        return selectWhere;
    }
View Full Code Here


    @Test
         public void should_build_from_clustering_keys_ascending_inclusive() throws Exception {
        //Given
        ClusteringOrder clusteringOrder = new ClusteringOrder("col1", Sorting.ASC);
        final Where where = QueryBuilder.select().from("table").where();

        //When
        INCLUSIVE_BOUNDS.buildFromClusteringKeys(where, clusteringOrder, clusteringKeyNames);

        //Then
        assertThat(where.toString()).isEqualToIgnoringCase("SELECT * FROM table WHERE (col1,col2)>=(:col1,:col2);");
    }
View Full Code Here

    @Test
    public void should_build_from_clustering_keys_ascending_exclusive() throws Exception {
        //Given
        ClusteringOrder clusteringOrder = new ClusteringOrder("col1", Sorting.ASC);
        final Where where = QueryBuilder.select().from("table").where();

        //When
        EXCLUSIVE_BOUNDS.buildFromClusteringKeys(where, clusteringOrder, clusteringKeyNames);

        //Then
        assertThat(where.toString()).isEqualToIgnoringCase("SELECT * FROM table WHERE (col1,col2)>(:col1,:col2);");
    }
View Full Code Here

    @Test
    public void should_build_from_clustering_keys_descending_inclusive() throws Exception {
        //Given
        ClusteringOrder clusteringOrder = new ClusteringOrder("col1", Sorting.DESC);
        final Where where = QueryBuilder.select().from("table").where();

        //When
        INCLUSIVE_BOUNDS.buildFromClusteringKeys(where, clusteringOrder, clusteringKeyNames);

        //Then
        assertThat(where.toString()).isEqualToIgnoringCase("SELECT * FROM table WHERE (col1,col2)<=(:col1,:col2);");
    }
View Full Code Here

    @Test
    public void should_build_from_clustering_keys_descending_exclusive() throws Exception {
        //Given
        ClusteringOrder clusteringOrder = new ClusteringOrder("col1", Sorting.DESC);
        final Where where = QueryBuilder.select().from("table").where();

        //When
        EXCLUSIVE_BOUNDS.buildFromClusteringKeys(where, clusteringOrder, clusteringKeyNames);

        //Then
        assertThat(where.toString()).isEqualToIgnoringCase("SELECT * FROM table WHERE (col1,col2)<(:col1,:col2);");
    }
View Full Code Here

    @Test
    public void should_build_to_clustering_keys_ascending_inclusive() throws Exception {
        //Given
        ClusteringOrder clusteringOrder = new ClusteringOrder("col1", Sorting.ASC);
        final Where where = QueryBuilder.select().from("table").where();

        //When
        INCLUSIVE_BOUNDS.buildToClusteringKeys(where, clusteringOrder, clusteringKeyNames);

        //Then
        assertThat(where.toString()).isEqualToIgnoringCase("SELECT * FROM table WHERE (col1,col2)<=(:col1,:col2);");
    }
View Full Code Here

    @Test
    public void should_build_to_clustering_keys_ascending_exclusive() throws Exception {
        //Given
        ClusteringOrder clusteringOrder = new ClusteringOrder("col1", Sorting.ASC);
        final Where where = QueryBuilder.select().from("table").where();

        //When
        EXCLUSIVE_BOUNDS.buildToClusteringKeys(where, clusteringOrder, clusteringKeyNames);

        //Then
        assertThat(where.toString()).isEqualToIgnoringCase("SELECT * FROM table WHERE (col1,col2)<(:col1,:col2);");
    }
View Full Code Here

    @Test
    public void should_build_to_clustering_keys_descending_inclusive() throws Exception {
        //Given
        ClusteringOrder clusteringOrder = new ClusteringOrder("col1", Sorting.DESC);
        final Where where = QueryBuilder.select().from("table").where();

        //When
        INCLUSIVE_BOUNDS.buildToClusteringKeys(where, clusteringOrder, clusteringKeyNames);

        //Then
        assertThat(where.toString()).isEqualToIgnoringCase("SELECT * FROM table WHERE (col1,col2)>=(:col1,:col2);");
    }
View Full Code Here

    @Test
    public void should_build_to_clustering_keys_descending_exclusive() throws Exception {
        //Given
        ClusteringOrder clusteringOrder = new ClusteringOrder("col1", Sorting.DESC);
        final Where where = QueryBuilder.select().from("table").where();

        //When
        EXCLUSIVE_BOUNDS.buildToClusteringKeys(where, clusteringOrder, clusteringKeyNames);

        //Then
        assertThat(where.toString()).isEqualToIgnoringCase("SELECT * FROM table WHERE (col1,col2)>(:col1,:col2);");
    }
View Full Code Here

        final ImmutableMap<RetentionPolicy, ElementType> retentionPolicies = ImmutableMap.of(SOURCE, ANNOTATION_TYPE, RUNTIME, CONSTRUCTOR);

        manager.insert(new EntityWithEnumeratedConfig(id, ConsistencyLevel.LOCAL_ONE, elementTypes, retentionPolicies));

        //When
        final Where statement = select().from(TABLE_NAME).where(eq("id", bindMarker("id")));

        final TypedMap found = manager.nativeQuery(statement, id).first();

        //Then
        assertThat(found.getTyped("id")).isEqualTo(id);
View Full Code Here

TOP

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

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.