Examples of forStatementGeneration()


Examples of info.archinnov.achilles.internal.metadata.holder.PropertyMeta.forStatementGeneration()

        Insert insert = insertInto(metaConfig.getKeyspaceName(), metaConfig.getTableName());
        if (options.isIfNotExists()) {
            insert.ifNotExists();
        }

        idMeta.forStatementGeneration().generateInsertPrimaryKey(insert);

        for (PropertyMeta pm : pms) {
            String cql3ColumnName = pm.getCQL3ColumnName();
            insert.value(cql3ColumnName, bindMarker(cql3ColumnName));
        }
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.PropertyMeta.forStatementGeneration()

            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());
        }
    }

    public PreparedStatement prepareUpdateFields(Session session, EntityMeta entityMeta, List<PropertyMeta> pms, Options options) {
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.PropertyMeta.forStatementGeneration()

            if (!pm.structure().isStaticColumn()) {
                onlyStaticColumns = false;
            }
            if (i == 0) {
                assignments = pm.forStatementGeneration().prepareUpdateField(updateConditions);
            } else {
                assignments = pm.forStatementGeneration().prepareUpdateField(assignments);
            }
        }
        RegularStatement statement = prepareWhereClauseWithTTLForUpdate(idMeta, assignments, onlyStaticColumns, options);
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.PropertyMeta.forStatementGeneration()

                onlyStaticColumns = false;
            }
            if (i == 0) {
                assignments = pm.forStatementGeneration().prepareUpdateField(updateConditions);
            } else {
                assignments = pm.forStatementGeneration().prepareUpdateField(assignments);
            }
        }
        RegularStatement statement = prepareWhereClauseWithTTLForUpdate(idMeta, assignments, onlyStaticColumns, options);
        return session.prepare(statement.getQueryString());
    }
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.PropertyMeta.forStatementGeneration()

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

        RegularStatement statement = idMeta.forStatementGeneration().generateWhereClauseForSelect(staticMeta, from);
        return session.prepare(statement.getQueryString());
    }

    public Map<CQLQueryType, PreparedStatement> prepareSimpleCounterQueryMap(Session session) {
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.PropertyMeta.forStatementGeneration()

        Map<CQLQueryType, Map<String, PreparedStatement>> clusteredCounterPSMap = new HashMap<>();
        Map<String, PreparedStatement> incrStatementPerCounter = new HashMap<>();
        Map<String, PreparedStatement> decrStatementPerCounter = new HashMap<>();
        Map<String, PreparedStatement> selectStatementPerCounter = new HashMap<>();

        final PropertyMetaStatementGenerator statementGenerator = idMeta.forStatementGeneration();

        for (PropertyMeta counterMeta : meta.getAllCounterMetas()) {
            final String propertyName = counterMeta.getPropertyName();
            final String cql3ColumnName = counterMeta.getCQL3ColumnName();
            final boolean staticColumn = counterMeta.structure().isStaticColumn();
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.PropertyMeta.forStatementGeneration()

        final EntityMetaConfig metaConfig = entityMeta.config();

        Map<String, PreparedStatement> deletePSs = new HashMap<>();

        Delete mainFrom = delete().from(metaConfig.getKeyspaceName(), metaConfig.getTableName());
        RegularStatement mainStatement = idMeta.forStatementGeneration().generateWhereClauseForDelete(entityMeta.structure().hasOnlyStaticColumns(), mainFrom);
        deletePSs.put(metaConfig.getQualifiedTableName(), session.prepare(mainStatement.getQueryString()));

        return deletePSs;
    }
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.PropertyMeta.forStatementGeneration()

    @Test
    public void should_prepare_select_field_ps() throws Exception {
        PropertyMeta nameMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);
        when(nameMeta.structure().isCounter()).thenReturn(false);
        when(nameMeta.forStatementGeneration().prepareSelectField(isA(Selection.class))).thenReturn(select().column("name"));
        when(idMeta.forStatementGeneration().generateWhereClauseForSelect(Mockito.eq(fromNullable(nameMeta)), isA(Select.class)))
                .thenReturn(select("name").from("ks","table").where(eq("id",bindMarker("id"))));

        when(session.prepare(queryCaptor.capture())).thenReturn(ps);
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.PropertyMeta.forStatementGeneration()

        final Assignments assignments = update("ks","table").with();

        when(nameMeta.structure().isStaticColumn()).thenReturn(false);
        when(ageMeta.structure().isStaticColumn()).thenReturn(false);
        when(nameMeta.forStatementGeneration().prepareUpdateField(conditionsCaptor.capture())).thenReturn(assignments);
        when(ageMeta.forStatementGeneration().prepareUpdateField(isA(Assignments.class))).thenReturn(assignments);
        when(idMeta.forStatementGeneration().prepareCommonWhereClauseForUpdate(assignments, false)).thenReturn(assignments.where(eq("id", bindMarker("id"))));
        when(session.prepare(queryCaptor.capture())).thenReturn(ps);

        PreparedStatement actual = generator.prepareUpdateFields(session, meta, asList(nameMeta, ageMeta),
                ifConditions(new CASCondition("name", "John")).withTimestamp(100L));
View Full Code Here

Examples of info.archinnov.achilles.internal.metadata.holder.PropertyMeta.forStatementGeneration()

    @Test
    public void should_prepare_select_eager_ps_with_single_key() throws Exception {
        PropertyMeta nameMeta = mock(PropertyMeta.class, RETURNS_DEEP_STUBS);

        when(meta.forOperations().getColumnsMetaToLoad()).thenReturn(asList(nameMeta));
        when(nameMeta.forStatementGeneration().prepareSelectField(isA(Selection.class))).thenReturn(select().column("name"));
        when(meta.structure().hasOnlyStaticColumns()).thenReturn(false);
        when(idMeta.forStatementGeneration().generateWhereClauseForSelect(Mockito.eq(Optional.<PropertyMeta>absent()), isA(Select.class)))
                .thenReturn(select("name").from("ks","table").where(eq("id", bindMarker("id"))));

        when(session.prepare(queryCaptor.capture())).thenReturn(ps);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.