Package com.datastax.driver.core.querybuilder.Update

Examples of com.datastax.driver.core.querybuilder.Update.Assignments


    public Pair<Assignments, Object[]> generateUpdateForSetAtIndexElement(Update.Conditions conditions) {
        final ElementAtIndex elementAtIndex = getEncodedListChangeAtIndex();
        final int index = elementAtIndex.getIndex();
        final Object encoded = elementAtIndex.getElement();
        Assignments assignments = propertyMeta.forStatementGeneration().generateUpdateForSetAtIndexElement(conditions, index, encoded);
        return Pair.create(assignments, new Object[] { index, encoded });
    }
View Full Code Here


        Assignments assignments = propertyMeta.forStatementGeneration().generateUpdateForSetAtIndexElement(conditions, index, encoded);
        return Pair.create(assignments, new Object[] { index, encoded });
    }

    public Pair<Assignments, Object[]> generateUpdateForRemovedAtIndexElement(Update.Conditions conditions) {
        Assignments assignments = propertyMeta.forStatementGeneration().generateUpdateForRemovedAtIndexElement(conditions, listChangeAtIndex.index);
        return Pair.create(assignments, new Object[] { listChangeAtIndex.index, null });
    }
View Full Code Here

            for (CASCondition CASCondition : options.getCASConditions()) {
                updateConditions.and(CASCondition.toClauseForPreparedStatement());
            }
        }

        Assignments assignments = null;
        boolean onlyStaticColumns = true;
        for (int i = 0; i < pms.size(); i++) {
            PropertyMeta pm = pms.get(i);

            if (!pm.structure().isStaticColumn()) {
View Full Code Here

                conditions.and(CASCondition.toClauseForPreparedStatement());
            }
        }

        CollectionAndMapChangeType changeType = changeSet.getChangeType();
        Assignments assignments = null;
        switch (changeType) {
            case ASSIGN_VALUE_TO_LIST:
            case ASSIGN_VALUE_TO_SET:
            case ASSIGN_VALUE_TO_MAP:
            case REMOVE_COLLECTION_OR_MAP:
View Full Code Here

        //Given
        when(meta.getCQL3ColumnName()).thenReturn("name");
        final Conditions conditions = update("table").onlyIf();

        //When
        final Assignments actual = view.prepareUpdateField(conditions);

        //Then
        assertThat(actual.getQueryString()).isEqualTo("UPDATE table SET name=:name;");
    }
View Full Code Here

    @Test
    public void should_prepare_update_fields_with_assignments() throws Exception {
        //Given
        when(meta.getCQL3ColumnName()).thenReturn("name");
        final Assignments assignments = update("table").with();

        //When
        final Assignments actual = view.prepareUpdateField(assignments);

        //Then
        assertThat(actual.getQueryString()).isEqualTo("UPDATE table SET name=:name;");
    }
View Full Code Here

    }

    @Test
    public void should_prepare_common_where_clause_for_update_with_embedded_id() throws Exception {
        //Given
        final Assignments assignments = update("table").with();
        when(meta.structure().isEmbeddedId()).thenReturn(true);
        when(embeddedIdProperties.getCQL3ComponentNames()).thenReturn(asList("id", "name"));

        //When
        final Where actual = view.prepareCommonWhereClauseForUpdate(assignments, false);
View Full Code Here

    }

    @Test
    public void should_prepare_common_where_clause_for_update_with_embedded_id_and_static_column() throws Exception {
        //Given
        final Assignments assignments = update("table").with();
        when(meta.structure().isEmbeddedId()).thenReturn(true);
        when(embeddedIdProperties.getPartitionComponents().getCQL3ComponentNames()).thenReturn(asList("id"));

        //When
        final Where actual = view.prepareCommonWhereClauseForUpdate(assignments, true);
View Full Code Here

    }

    @Test
    public void should_prepare_common_where_clause_for_update_with_simple_id() throws Exception {
        //Given
        final Assignments assignments = update("table").with();
        when(meta.structure().isEmbeddedId()).thenReturn(false);
        when(meta.getCQL3ColumnName()).thenReturn("id");

        //When
        final Where actual = view.prepareCommonWhereClauseForUpdate(assignments, true);
View Full Code Here

        CompleteBean pk = new CompleteBean();
        PropertyMeta pm = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);

        when(meta.forValues().getPrimaryKey(entity)).thenReturn(pk);

        final Assignments assignments = update("table").with();
        when(meta.structure().isEmbeddedId()).thenReturn(true);
        when(embeddedIdProperties.getCQL3ComponentNames()).thenReturn(asList("id", "name"));
        when(pm.structure().isStaticColumn()).thenReturn(false);
        when(meta.forTranscoding().encodeToComponents(pk, false)).thenReturn(Arrays.<Object>asList(10L, "DuyHai"));
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.querybuilder.Update.Assignments

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.