Apache ignite:找不到列ID。即使在那儿

问题描述 投票:0回答:1

大家好,我正在dBeaver控制台上收到一条消息。在表'“ BusinesslogicsCache” .BUSINESSLOGICS'中找不到PK的列'businesslogicid''“ BusinesslogicsCache” .BUSINESSLOGICS。“ businesslogicid”'

此businesslogicid在高速缓存和高速缓存配置中。

查询:-

SELECT LOGICNAME,配置,CREATEDON,MODIFIEDON,CREATEDBY,MODIFIEDBY,ISACTIVE和BUSINESSLOGICID来自“ BusinesslogicsCache” .BUSINESSLOGICS;

具有jdbctypes的表配置

public static CacheConfiguration cacheBusinesslogicsCache() throws Exception {
        CacheConfiguration ccfg = new CacheConfiguration();

        ccfg.setName("BusinesslogicsCache");
        ccfg.setCacheMode(CacheMode.PARTITIONED);
        ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);

    CacheJdbcPojoStoreFactory cacheStoreFactory = new CacheJdbcPojoStoreFactory();

    cacheStoreFactory.setDataSourceFactory(new Factory<DataSource>() {
        /** {@inheritDoc} **/
        @Override
        public DataSource create() {
            return DataSources.INSTANCE_dsMySQL_CcplatformQa;
        };
    });

    cacheStoreFactory.setDialect(new MySQLDialect());

    cacheStoreFactory.setTypes(jdbcTypeBusinesslogics(ccfg.getName()));

    ccfg.setCacheStoreFactory(cacheStoreFactory);

    ccfg.setReadThrough(true);
    ccfg.setWriteThrough(true);
    ccfg.setBackups(1);

    ArrayList<QueryEntity> qryEntities = new ArrayList<>();

    QueryEntity qryEntity = new QueryEntity();

    qryEntity.setKeyType("java.lang.Long");
    qryEntity.setValueType("org.netlink.ignite.model.Businesslogics");
    qryEntity.setKeyFieldName("businesslogicid");

    HashSet<String> keyFields = new HashSet<>();

    keyFields.add("businesslogicid");

    qryEntity.setKeyFields(keyFields);

    LinkedHashMap<String, String> fields = new LinkedHashMap<>();

    fields.put("logicname", "java.lang.String");
    fields.put("type", "java.lang.String");
    fields.put("configuration", "java.lang.String");
    fields.put("createdon", "java.sql.Timestamp");
    fields.put("modifiedon", "java.sql.Timestamp");
    fields.put("createdby", "java.lang.Long");
    fields.put("modifiedby", "java.lang.Long");
    fields.put("isactive", "java.lang.Boolean");
    fields.put("businesslogicid", "java.lang.Long");

    qryEntity.setFields(fields);

    ArrayList<QueryIndex> indexes = new ArrayList<>();

    QueryIndex index = new QueryIndex();

    index.setName("createdBy");
    index.setIndexType(QueryIndexType.SORTED);

    LinkedHashMap<String, Boolean> indFlds = new LinkedHashMap<>();

    indFlds.put("createdby", false);

    index.setFields(indFlds);
    indexes.add(index);

    index = new QueryIndex();

    index.setName("modifiedBy");
    index.setIndexType(QueryIndexType.SORTED);

    indFlds = new LinkedHashMap<>();

    indFlds.put("modifiedby", false);

    index.setFields(indFlds);
    indexes.add(index);

    qryEntity.setIndexes(indexes);
    qryEntities.add(qryEntity);

    ccfg.setQueryEntities(qryEntities);

    return ccfg;
}

/**
 * Create JDBC type for "jdbcTypeBusinesslogics".
 * 
 * @param cacheName Cache name.
 * @return Configured JDBC type.
 **/
private static JdbcType jdbcTypeBusinesslogics(String cacheName) {
    JdbcType type = new JdbcType();

    type.setCacheName(cacheName);
    type.setKeyType(Long.class);
    type.setValueType("org.netlink.ignite.model.Businesslogics");
    type.setDatabaseSchema(schema);
    type.setDatabaseTable("businesslogics");

    type.setKeyFields(new JdbcTypeField(Types.BIGINT, "businessLogicId", long.class, "businesslogicid"));

    type.setValueFields(new JdbcTypeField(Types.VARCHAR, "logicName", String.class, "logicname"),
            new JdbcTypeField(Types.VARCHAR, "type", String.class, "type"),
            new JdbcTypeField(Types.LONGVARCHAR, "configuration", String.class, "configuration"),
            new JdbcTypeField(Types.TIMESTAMP, "createdOn", Timestamp.class, "createdon"),
            new JdbcTypeField(Types.TIMESTAMP, "modifiedOn", Timestamp.class, "modifiedon"),
            new JdbcTypeField(Types.BIGINT, "createdBy", long.class, "createdby"),
            new JdbcTypeField(Types.BIGINT, "modifiedBy", long.class, "modifiedby"),
            new JdbcTypeField(Types.BIT, "isActive", boolean.class, "isactive"));

    return type;
}

请指导我。

ignite
1个回答
0
投票

我认为您应该删除setKeyFields,因为仅当您的密钥不是原始类型时才需要它。

© www.soinside.com 2019 - 2024. All rights reserved.