我试试这个并且工作正常。
@Autowired
private CassandraOperations cassandraOperations;
in my method
{
String cqlAll = "select * from customer where cust_id=123";
List<Customer> results = cassandraOperations.select(cqlAll, Customer.class);
for (Customer p : results)
{
System.out.println(p.getCust_id() + "-"+p.getCust_name()+"-"+p.getCust_password());
}
}
但我想将值传递给字符串,以便我可以单独编写查询文件。像这样的东西,
String cqlAll = "select * from customer where cust_id=?";
objects[] obj = {123};
List<Customer> results = cassandraOperations.select(cqlAll, obj ,Customer.class);
for (Customer p : results)
{
System.out.println(p.getCust_id() + "-"+p.getCust_name()+"-"+
p.getCust_password());
}