Package info.archinnov.achilles.internal.metadata.holder

Examples of info.archinnov.achilles.internal.metadata.holder.EntityMetaConfig


        log.debug("Start schema validation/creation");
        Map<String, TableMetadata> tableMetaDatas = schemaContext.fetchTableMetaData();

        for (Entry<Class<?>, EntityMeta> entry : schemaContext.entityMetaEntrySet()) {
            EntityMeta entityMeta = entry.getValue();
            final EntityMetaConfig metaConfig = entityMeta.config();
            String qualifiedTableName = metaConfig.getQualifiedTableName().toLowerCase();

            if (tableMetaDatas.containsKey(qualifiedTableName)) {
                TableMetadata tableMetaData = tableMetaDatas.get(qualifiedTableName);
                schemaContext.validateForEntity(entityMeta, tableMetaData);
                schemaContext.updateForEntity(entityMeta, tableMetaData);
View Full Code Here


        Validator.validateNotNull(indexCondition, "Index condition should not be null");

        entityMeta.forTranscoding().encodeIndexConditionValue(indexCondition);

        String indexColumnName = indexCondition.getColumnName();
        final EntityMetaConfig metaConfig = entityMeta.config();
        final Select.Where statement = select().from(metaConfig.getKeyspaceName(), metaConfig.getTableName()).where(eq(indexColumnName, bindMarker(indexColumnName)));
        return this.typedQueryInternal(entityClass, statement, indexCondition.getColumnValue());
    }
View Full Code Here

    public Pair<Update.Where, Object[]> generateCollectionAndMapUpdateOperation(PersistentStateHolder context, DirtyCheckChangeSet changeSet) {
        log.trace("Generate collection/map update operation for dirty change set {}", changeSet);

        final Object entity = context.getEntity();
        final EntityMeta meta = context.getEntityMeta();
        final EntityMetaConfig metaConfig = meta.config();

        final Optional<Integer> ttlO = context.getTtl();
        final Optional<Long> timestampO = context.getTimestamp();
        final List<CASCondition> CASConditions = context.getCasConditions();

        final Update.Conditions conditions = update(metaConfig.getKeyspaceName(), metaConfig.getTableName()).onlyIf();
        List<Object> casEncodedValues = addAndEncodeCasConditions(meta, CASConditions, conditions);

        Object[] boundValues = new Object[] { };
        if (ttlO.isPresent()) {
            conditions.using(ttl(ttlO.get()));
View Full Code Here

    private static final Logger log = LoggerFactory.getLogger(PreparedStatementGenerator.class);

    public PreparedStatement prepareInsert(Session session, EntityMeta entityMeta, List<PropertyMeta> pms, Options options) {
        log.trace("Generate prepared statement for INSERT on {}", entityMeta);
        PropertyMeta idMeta = entityMeta.getIdMeta();
        final EntityMetaConfig metaConfig = entityMeta.config();
        Insert insert = insertInto(metaConfig.getKeyspaceName(), metaConfig.getTableName());
        if (options.isIfNotExists()) {
            insert.ifNotExists();
        }

        idMeta.forStatementGeneration().generateInsertPrimaryKey(insert);
View Full Code Here

        if (pm.structure().isCounter()) {
            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());
        }
    }
View Full Code Here

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

        log.trace("Generate prepared statement for UPDATE properties {}", pms);

        PropertyMeta idMeta = entityMeta.getIdMeta();
        final EntityMetaConfig metaConfig = entityMeta.config();
        Update update = update(metaConfig.getKeyspaceName(), metaConfig.getTableName());
        final Update.Conditions updateConditions = update.onlyIf();
        if (options.hasCASConditions()) {
            for (CASCondition CASCondition : options.getCASConditions()) {
                updateConditions.and(CASCondition.toClauseForPreparedStatement());
            }
View Full Code Here

    public PreparedStatement prepareSelectAll(Session session, EntityMeta entityMeta) {
        log.trace("Generate prepared statement for SELECT of {}", entityMeta);

        PropertyMeta idMeta = entityMeta.getIdMeta();
        final EntityMetaConfig metaConfig = entityMeta.config();
        Selection select = select();

        for (PropertyMeta pm : entityMeta.forOperations().getColumnsMetaToLoad()) {
            select = pm.forStatementGeneration().prepareSelectField(select);
        }
        Select from = select.from(metaConfig.getKeyspaceName(), metaConfig.getTableName());

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

        return counterPSMap;
    }

    public Map<CQLQueryType, Map<String, PreparedStatement>> prepareClusteredCounterQueryMap(Session session, EntityMeta meta) {
        PropertyMeta idMeta = meta.getIdMeta();
        final EntityMetaConfig metaConfig = meta.config();
        String keyspaceName = metaConfig.getKeyspaceName();
        String tableName = metaConfig.getTableName();

        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<>();
View Full Code Here

    public Map<String, PreparedStatement> prepareDeletePSs(Session session, EntityMeta entityMeta) {

        log.trace("Generate prepared statement for DELETE of {}", entityMeta);

        PropertyMeta idMeta = entityMeta.getIdMeta();
        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

        return deletePSs;
    }

    public PreparedStatement prepareCollectionAndMapUpdate(Session session, EntityMeta meta, DirtyCheckChangeSet changeSet, Options options) {
        final EntityMetaConfig metaConfig = meta.config();

        final Update.Conditions conditions = update(metaConfig.getKeyspaceName(), metaConfig.getTableName()).onlyIf();

        if (options.hasCASConditions()) {
            for (CASCondition CASCondition : options.getCASConditions()) {
                conditions.and(CASCondition.toClauseForPreparedStatement());
            }
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.internal.metadata.holder.EntityMetaConfig

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.