【发布时间】:2020-12-07 10:30:40
【问题描述】:
我的桌子如下,
create table contact( id uuid primary key,
personName text,
updatedTime timestamp
);
并尝试执行下面的准备语句,
String query = "SELECT * FROM CONTACT WHERE personName IN (:personNameList) " +
"AND updatedTime > ':startTime' AND updatedTime < :endTime ALLOW FILTERING;";
SimpleStatement simpleStatement = SimpleStatement.builder(query)
.setConsistencyLevel(DefaultConsistencyLevel.QUORUM)
.build();
PreparedStatement preparedStatement = cqlSession.prepare(simpleStatement);
BoundStatement boundStatement = preparedStatement.bind();
personList = ["John","Alex"];
boundStatement.setString("startTime", "2020-08-16 14:44:32+0000"); // Issue with setting
boundStatement.setString("endTime", "2020-08-16 14:60:32+0000"); // Issue with setting
boundStatement.setList("personNameList", personList, String.class); // Codec not found for requested operation: [TEXT <-> java.util.List<java.lang.String>]
ResultSet execute = cqlSession.execute(boundStatement);
// List<Person> personList = // Mapping
从驱动映射的 4.7.2 开始,根据我的理解,它与映射的类型不同,我无法从谷歌得到答案。有什么建议吗?
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-mapper-processor</artifactId>
<version>4.7.2</version>
<scope>test</scope>
</dependency>
【问题讨论】:
标签: datastax datastax-java-driver