我有一个以字符串为 ID 的 kundera 模型实体。它是这样定义的。
@Id
private String id;
我有一个方法,我正在执行这样的本机查询。
/**
* @param requestId
* @return
*/
public static ProcessRequest getRequest(Serializable requestId) {
List<ProcessRequest> requests = execute("SELECT * from
process_requests where id = '" + requestId + "';");
return requests.isEmpty() ? null : requests.get(0);
}
像这样运行单元测试时出现以下异常。
17:50:38.716 [main] ERROR c.i.c.cassandra.CassandraClientBase - Error during executing query SELECT * from process_requests where id = '5b4468e0-6146-4fbc-81cf-571371834446';, Caused by: {} .
com.impetus.kundera.KunderaException: InvalidRequestException(why:Undefined name id in where clause ('id EQ '5b4468e0-6146-4fbc-81cf-571371834446''))
at com.impetus.client.cassandra.CassandraClientBase.execute(CassandraClientBase.java:2101) [kundera-cassandra-2.14.jar:na]
at com.impetus.client.cassandra.CassandraClientBase.executeCQLQuery(CassandraClientBase.java:1708) [kundera-cassandra-2.14.jar:na]
at com.impetus.client.cassandra.CassandraClientBase$CQLClient.executeQuery(CassandraClientBase.java:1851) [kundera-cassandra-2.14.jar:na]
at com.impetus.client.cassandra.CassandraClientBase.executeSelectQuery(CassandraClientBase.java:761) [kundera-cassandra-2.14.jar:na]
at com.impetus.client.cassandra.thrift.ThriftClient.executeQuery(ThriftClient.java:860) [kundera-cassandra-2.14.jar:na]
at com.impetus.client.cassandra.query.CassQuery.populateEntities(CassQuery.java:143) [kundera-cassandra-2.14.jar:na]
at com.impetus.kundera.query.QueryImpl.fetch(QueryImpl.java:1013) [kundera-core-2.14.jar:na]
at com.impetus.kundera.query.QueryImpl.getResultList(QueryImpl.java:164) [kundera-core-2.14.jar:na]
即使有一个由 id 定义的列,它也会给出这个异常,我已经详尽地寻求帮助并且无法解决它。你能帮忙解决这个问题吗?
更新:
CREATE TABLE docyard.process_requests (
id text PRIMARY KEY,
content_type text,
created_at timestamp,
document_id text,
lock bigint,
lock_expiration timestamp,
namespace text,
process_input text,
process_output text,
processed text,
updated_at timestamp,
version_id text
) WITH bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND comment = ''
AND compaction = {'min_threshold': '4', 'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32'}
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99.0PERCENTILE';
CREATE INDEX process_requests_lock_idx ON docyard.process_requests (lock);
CREATE INDEX process_requests_processed_idx ON docyard.process_requests (processed);