Package com.datastax.driver.core

Examples of com.datastax.driver.core.RegularStatement


        // Given
        CompleteBean entity = builder().randomId().name("DuyHai").label("label").buid();

        manager.insert(entity);

        RegularStatement statement = select().from("CompleteBean").where(eq("id",bindMarker()));

        // When
        final CompleteBean actual = manager.typedQuery(CompleteBean.class, statement,entity.getId()).getFirst();

        // Then
View Full Code Here


        // Given
        CompleteBean entity = builder().randomId().name("DuyHai").label("label").buid();

        manager.insert(entity);

        RegularStatement statement = select().from("CompleteBean").where(eq("id",bindMarker()));

        // When
        final CompleteBean actual = manager.rawTypedQuery(CompleteBean.class, statement,entity.getId()).getFirst();

        // Then
View Full Code Here

    }

    @Test
    public void should_validate_raw_typed_query() throws Exception {
        //Given
        final RegularStatement statement = select().from("ks", "table").where(eq("id", 10L));

        //When
        validator.validateRawTypedQuery(CompleteBean.class, statement, meta);

        //Then
View Full Code Here

    @Test
    public void should_validate_raw_typed_query_without_keyspace() throws Exception {
        //Given
        when(meta.config().getTableName()).thenReturn("service_profile");

        final RegularStatement statement = select().from("service_profile").where();

        //When
        validator.validateRawTypedQuery(CompleteBean.class, statement, meta);

        //Then
View Full Code Here

    }


    @Test
    public void should_exception_when_wrong_table() throws Exception {
        final RegularStatement statement = select().from("ks", "test").where(eq("id", 10L));

        exception.expect(AchillesException.class);
        exception.expectMessage(format("The typed query [SELECT * FROM ks.test WHERE id=10;] should contain the table name 'table' if type is '%s'", CompleteBean.class.getCanonicalName()));

        validator.validateRawTypedQuery(CompleteBean.class, statement, meta);
View Full Code Here

    public void should_exception_when_missing_id_column() throws Exception {
        PropertyMeta idMeta = PropertyMetaTestBuilder.completeBean(Void.class, Long.class).propertyName("id").cqlColumnName("id").type(PropertyType.ID).build();

        when(meta.getIdMeta()).thenReturn(idMeta);

        final RegularStatement statement = select("name","age").from("table").where(eq("col", 10L));

        exception.expect(AchillesException.class);
        exception.expectMessage("The typed query [select name,age from table where col=10;] should contain the id column 'id'");

        validator.validateTypedQuery(CompleteBean.class, statement, meta);
View Full Code Here

    public void should_skip_id_column_validation_when_select_star() throws Exception {
        PropertyMeta idMeta = PropertyMetaTestBuilder.completeBean(Void.class, Long.class).propertyName("id").type(PropertyType.ID).build();

        when(meta.getIdMeta()).thenReturn(idMeta);

        final RegularStatement statement = select().from("table").where(eq("id",10L));

        validator.validateTypedQuery(CompleteBean.class, statement, meta);
    }
View Full Code Here


    @Test(expected = AchillesException.class)
    public void should_exception_when_not_SELECT_statement() throws Exception {
        //Given
        RegularStatement statement = QueryBuilder.insertInto("test");

        //When
        validator.validateRawTypedQuery(CompleteBean.class,statement,meta);

        //Then
View Full Code Here

        manager = factory.createPersistenceManager();
    }

    @Test
    public void should_bootstrap_achilles_without_entity_package_for_native_query() throws Exception {
        RegularStatement statement = select("keyspace_name").from("system","schema_keyspaces").where(eq("keyspace_name","system"));

        Map<String, Object> keyspaceMap = manager.nativeQuery(statement).first();

        assertThat(keyspaceMap).hasSize(1);
        assertThat(keyspaceMap.get("keyspace_name")).isEqualTo("system");
View Full Code Here

        entity.setWelcomeTweet(welcomeTweet);

        entity.getVersion().incr(10L);
        batch.update(entity);

        RegularStatement selectLabel = select("label").from("CompleteBean").where(eq("id",entity.getId()));
        Map<String, Object> result = manager.nativeQuery(selectLabel).first();
        assertThat(result).isNull();

        RegularStatement selectCounter = select("counter_value")
                .from("achilles_counter_table")
                .where(eq("fqcn",CompleteBean.class.getCanonicalName()))
                .and(eq("primary_key",entity.getId().toString()))
                .and(eq("property_name","version"));
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.