点燃查询异常

时间:2017-11-25 12:12:34

标签: ignite

我收到以下错误:

Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "SELECT 
""standard_item_cache"".""STANDARDITEM""._KEY, 
""standard_item_cache"".""STANDARDITEM""._VAL FROM 
""standard_item_cache"".""STANDARDITEM"" WHERE ITEMID[*] == ? "; SQL statement:
SELECT "standard_item_cache"."STANDARDITEM"._KEY, 
"standard_item_cache"."STANDARDITEM"._VAL FROM 
"standard_item_cache"."STANDARDITEM" WHERE itemId == ? [42000-196]

当我尝试执行简单查询时:

String itemId = params.get(Params.PARAM_ITEM_ID);

SqlQuery<String, StandardItem> sql = new SqlQuery<>(StandardItem.class, "itemid == ?");

try (QueryCursor<Cache.Entry<String, StandardItem>> cursor = standardItemIgniteCache.query(sql.setArgs(itemId))) {
    logger.info("publish standard items from cache");

    for (Cache.Entry<String, StandardItem> entry : cursor) {
        logger.info("publish standard item: " + entry.getValue().toString());
    }

    logger.info("publishing standard items from cache done");

    cursor.close();
}

错误在哪里?我完全像在apache点燃示例中描述的那样:https://apacheignite.readme.io/v1.0/docs/cache-queries

1 个答案:

答案 0 :(得分:3)

错误在于这个微小的字符串:itemid == ?

您使用==代替=。 SQL相等运算符是单个=