Package com.datastax.driver.core

Examples of com.datastax.driver.core.RegularStatement


        final List<Object> clusteringKeys = Arrays.<Object>asList(20140830, PropertyType.COUNTER);

        final Select select = select().from("table");

        //When
        final RegularStatement statement = SliceQueryProperties.builder(meta, ClusteredEntity.class, SliceType.SELECT)
                .partitionKeysName(asList("id", "bucket")).partitionKeys(partitionKeys)
                .fromClusteringKeysName(asList("date")).fromClusteringKeys(clusteringKeys)
                .toClusteringKeysName(asList("date", "type")).toClusteringKeys(clusteringKeys)
                .bounding(BoundingMode.EXCLUSIVE_BOUNDS)
                .limit(12)
                .generateWhereClauseForSelect(select);

        //Then
        assertThat(statement.getQueryString()).isEqualTo("SELECT * FROM table WHERE id=:id AND bucket=:bucket AND (date)<(:date) AND (date,type)>(:date,:type) LIMIT :limitSize;");
    }
View Full Code Here


        final List<Object> clusteringKeys = Arrays.<Object>asList(20140830, PropertyType.COUNTER);

        final Select select = select().from("table");

        //When
        final RegularStatement statement = SliceQueryProperties.builder(meta, ClusteredEntity.class, SliceType.SELECT)
                .partitionKeysName(asList("id", "bucket")).partitionKeys(partitionKeys)
                .fromClusteringKeysName(asList("date")).fromClusteringKeys(clusteringKeys)
                .toClusteringKeysName(asList("date", "type")).toClusteringKeys(clusteringKeys)
                .bounding(BoundingMode.INCLUSIVE_BOUNDS)
                .ordering(null)
                .limit(12)
                .generateWhereClauseForSelect(select);

        //Then
        assertThat(statement.getQueryString()).isEqualTo("SELECT * FROM table WHERE id=:id AND bucket=:bucket AND (date)<=(:date) AND (date,type)>=(:date,:type) LIMIT :limitSize;");
    }
View Full Code Here

        final List<Object> clusteringKeys = Arrays.<Object>asList(20140830, PropertyType.COUNTER);

        final Delete delete = delete().from("table");

        //When
        final RegularStatement statement = SliceQueryProperties.builder(meta, ClusteredEntity.class, SliceType.SELECT)
                .partitionKeysName(asList("id", "bucket")).lastPartitionKeyName("year")
                .partitionKeys(partitionKeys).andPartitionKeysIn(partitionKeysIN)
                .withClusteringKeysName(asList("date", "type"))
                .withClusteringKeys(clusteringKeys)
                .generateWhereClauseForDelete(delete);

        //Then
        assertThat(statement.getQueryString()).isEqualTo("DELETE FROM table WHERE id=:id AND bucket=:bucket AND year IN :partitionComponentsIn AND date=:date AND type=:type;");
    }
View Full Code Here

        final SelectFromPartition<String> start = builder
                .withPartitionComponents("a");

        start.limit(3).get(10);

        final RegularStatement whereClause = start.properties.generateWhereClauseForSelect(select);

        //Then
        assertThat(whereClause.getQueryString()).isEqualTo("SELECT * FROM table WHERE id=:id LIMIT :limitSize;");
        assertThat(start.properties.getBoundValues()).containsSequence("a", 10);
    }
View Full Code Here

        final SelectFromPartition<String> start = builder
                .withPartitionComponents("a");

        start.limit(3).async().get(10);

        final RegularStatement whereClause = start.properties.generateWhereClauseForSelect(select);

        //Then
        assertThat(whereClause.getQueryString()).isEqualTo("SELECT * FROM table WHERE id=:id LIMIT :limitSize;");
        assertThat(start.properties.getBoundValues()).containsSequence("a", 10);
    }
View Full Code Here

        final SelectWithPartition<String> start = builder
                .withPartitionComponentsIN("a", "b");

        start.limit(2).fromClusterings("A","B").limit(3).orderByAscending().get(10);

        final RegularStatement whereClause = start.properties.generateWhereClauseForSelect(select);

        //Then
        assertThat(whereClause.getQueryString()).isEqualTo("SELECT * FROM table WHERE bucket IN :partitionComponentsIn AND (col1,col2)>=(:col1,:col2) ORDER BY col1 ASC LIMIT :limitSize;");
        assertThat(start.properties.getBoundValues()).containsSequence(asList("a","b"), "A","B",10);
    }
View Full Code Here

        final SelectFromPartition<String> start = builder
                .withPartitionComponents("a");

        start.limit(3).orderByDescending().getOne();

        final RegularStatement whereClause = start.properties.generateWhereClauseForSelect(select);

        //Then
        assertThat(whereClause.getQueryString()).isEqualTo("SELECT * FROM table WHERE id=:id ORDER BY col1 DESC LIMIT :limitSize;");
        assertThat(start.properties.getBoundValues()).containsSequence("a", 1);
    }
View Full Code Here

        final SelectFromPartition<String> start = builder
                .withPartitionComponents("a");

        start.limit(3).async().getOne();

        final RegularStatement whereClause = start.properties.generateWhereClauseForSelect(select);

        //Then
        assertThat(whereClause.getQueryString()).isEqualTo("SELECT * FROM table WHERE id=:id LIMIT :limitSize;");
        assertThat(start.properties.getBoundValues()).containsSequence("a", 1);
    }
View Full Code Here

            .withConsistency(QUORUM)
            .fromClusterings("A", "B")
            .toClusterings("C", "D")
            .get(10);

        final RegularStatement whereClause = start.properties.generateWhereClauseForSelect(select);

        //Then
        assertThat(whereClause.getQueryString()).isEqualTo("SELECT * FROM table WHERE id=:id AND bucket IN :partitionComponentsIn AND (col1,col2)>=(:col1,:col2) AND (col1,col2)<=(:col1,:col2) LIMIT :limitSize;");
        assertThat(start.properties.getBoundValues()).containsSequence("a", asList("b", "c"), "A", "B", "C", "D", 10);
    }
View Full Code Here

        start.limit(3)
                .withClusterings("A", "B")
                .andClusteringsIN("C", "D")
                .getOne();

        final RegularStatement whereClause = start.properties.generateWhereClauseForSelect(select);

        //Then
        assertThat(whereClause.getQueryString()).isEqualTo("SELECT * FROM table WHERE id=:id AND col1=:col1 AND col2=:col2 AND col3 IN :clusteringKeysIn LIMIT :limitSize;");
        assertThat(start.properties.getBoundValues()).containsSequence("a", "A", "B", asList("C", "D"), 1);
    }
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.RegularStatement

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.