Cassandra 不使用 CQL 更新数据,而是使用 mutator 更新数据
使用以下代码,我尝试更新一行。
Keyspace fKeyspace = HFactory.createKeyspace(KEYSPACE, fCluster);
// Update with CQL
CqlQuery<String,String,String> cqlQuery =
new CqlQuery<String,String,String>(fKeyspace, fStringS, fStringS, fStringS);
cqlQuery.setQuery(
"INSERT INTO Fahrer (KEY, 'first') VALUES('fahrer1', 'FirstnameUpdated')");
QueryResult<CqlRows<String,String,String>> result = cqlQuery.execute();
// Update with mutator
Mutator<String> mutator = HFactory.createMutator(fKeyspace, fStringS);
MutationResult mr = mutator.insert("fahrer2", "Fahrer",
HFactory.createStringColumn("first", "SecondUpdated"));
不执行 CQL 查询的更新,而是执行使用变元的更新。错误在哪里?
With the following code I try to update a row
Keyspace fKeyspace = HFactory.createKeyspace(KEYSPACE, fCluster);
// Update with CQL
CqlQuery<String,String,String> cqlQuery =
new CqlQuery<String,String,String>(fKeyspace, fStringS, fStringS, fStringS);
cqlQuery.setQuery(
"INSERT INTO Fahrer (KEY, 'first') VALUES('fahrer1', 'FirstnameUpdated')");
QueryResult<CqlRows<String,String,String>> result = cqlQuery.execute();
// Update with mutator
Mutator<String> mutator = HFactory.createMutator(fKeyspace, fStringS);
MutationResult mr = mutator.insert("fahrer2", "Fahrer",
HFactory.createStringColumn("first", "SecondUpdated"));
The update of the CQL-query is not performed, the update with the mutator is performed. Where is the mistake?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎调换了键名和列名。对于钥匙你有:
变元上的“fahrer2”和 CQL 查询上的“first”。
如果您还没有,请参阅以下内容以了解有关 Hector 中的 CQL(以及一般情况)的更多信息:
https://github.com/rantav/hector/wiki/Using-CQL
You appear to have your key and column name transposed. For keys you have:
"fahrer2" on the mutator and "first" on the CQL query.
If you have not already, please see the following for more on CQL in Hector (and in general):
https://github.com/rantav/hector/wiki/Using-CQL