我有一个关于使用spring cassandra存储库来搜索查询的问题 . 我有一个表,其中一个分区键和一个群集键一起作为复合主键 . 所以在映射层,我使用@PrimaryKeyClass和@PrimaryKeyColumn为PrimanyKey创建一个类,然后使用@PrimaryKey作为映射类
该表是使用以下cql创建的
CREATE TABLE user_mobile (phonenum text,memberid uuid,gender text,nickname text,photo timeuuid,PRIMARY KEY (phonenum, memberid))
我创建了一个名为PK_UserMobile的类作为主键类
@PrimaryKeyClass
public class PK_UserMobile implements Serializable {
@PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED)
private String phoneNum;
@PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.CLUSTERED)
private UUID memberId;
......
}
我的映射类是这样的
@Table("user_mobile")
public class UserMobile extends BaseDto {
@PrimaryKey
private PK_UserMobile pk;
........
}
可以运行cql,例如“select * from user_mobile,其中phonenum ='xxxxxxxxx';” . 所以我想只用分区键来搜索这个表是好的 . 当我尝试使用spring cassandra存储库进行搜索时,似乎需要我提供phonenum和memberid的搜索用法值 . 如果我只设置phonenum的值,则抛出以下异常 .
"com.datastax.driver.core.exceptions.InvalidQueryException: Invalid null value in condition for column memberid. "
所以我想知道是否应该将任何特殊的空对象作为搜索条件传入聚类键?或者我应该以其他方式做到这一点?谢谢 .