使用DataStax驱动程序生成查询

使用DataStax驱动程序生成查询,datastax,datastax-java-driver,Datastax,Datastax Java Driver,我的桌子如下 create table contact( id uuid primary key, personName text, updatedTime timestamp ); 并尝试执行下面的prepare语句 String query = "SELECT * FROM CONTACT WHERE personName IN (:personN

我的桌子如下

create table contact( id uuid primary key, 
                      personName text, 
                      updatedTime timestamp
                    );
并尝试执行下面的prepare语句

 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

String query=“从personName所在的联系人中选择*(:personNameList)”+
“和UpdateTime>”:startTime“和UpdateTime<:endTime允许筛选;”;
SimpleStatement SimpleStatement=SimpleStatement.builder(查询)
.SetConsistenceLevel(DefaultConsistenceLevel.QUORUM)
.build();
PreparedStatement PreparedStatement=cqlSession.prepare(simpleStatement);
BoundStatement BoundStatement=preparedStatement.bind();
personList=[“约翰”、“亚历克斯”];
boundStatement.setString(“开始时间”,“2020-08-16 14:44:32+0000”);//设置问题
boundStatement.setString(“endTime”,“2020-08-16 14:60:32+0000”);//设置问题
boundStatement.setList(“personNameList”,personList,String.class);//找不到请求操作的编解码器:[TEXT java.util.List]
ResultSet execute=cqlSession.execute(boundStatement);
//List personList=//映射
从驱动程序映射的4.7.2开始,据我的理解,它与映射的类型不同,我无法从谷歌得到答案。有什么建议吗


 <dependency>
            <groupId>com.datastax.oss</groupId>
            <artifactId>java-driver-mapper-processor</artifactId>
            <version>4.7.2</version>
            <scope>test</scope>
        </dependency>


com.datastax.oss
java驱动程序映射处理器
4.7.2
测试

对象映射器在Java驱动程序4.x中发生了重大变化,因此需要生成工作所需的辅助类。但您仍然可以使用它将
对象转换为POJO,方法是在DAO接口中声明
GetEntry
,如下所示:

@Dao
public interface PersonDao {
  @GetEntity
  Person asPerson(Row row);
}
但若您打算使用对象映射器,我建议您在任何情况下都使用它——在您的情况下,您可以使用
查询
声明一个方法,并为绑定传递参数