我有一個kundera模型實體,它具有字符串作爲Id。它是這樣定義的。Kundera和Cassandra單元問題 - 字符串作爲主鍵
@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);
*搜索幫助詳盡 – 2015-03-31 12:29:18
在您的cassandra集羣上打開一個cqlsh會話,並編輯您的答案以包含'desc table process_requests'的輸出。 – Aaron 2015-03-31 13:37:13
我在我的問題中添加了表格說明。 – 2015-04-03 09:51:23