我正在尝试使用复合主键类使用 Spring Data Cassandra。但是当我尝试查询数据时出现异常:
org.springframework.data.repository.query.QueryCreationException: **Could not create query for public abstract java.util.List com.amdocs.cassandrapoc.repository.ServiceRepository.findByKey(com.amdocs.cassandrapoc.entities.Key)! Reason: Cannot use composite primary key directly. Reference a property of the composite primary key**
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
@PrimaryKeyClass
public class Key implements Serializable {
@PrimaryKeyColumn(name = "id", ordinal = 0, type =
PrimaryKeyType.PARTITIONED)
@CassandraType(type = DataType.Name.UUID)
private UUID id;
@PrimaryKeyColumn(name = "tenant", ordinal = 1, type =
PrimaryKeyType.PARTITIONED)
@CassandraType(type = DataType.Name.TEXT)
private String tenant;
(Equals, hashcode, getters, setters omitted)
}
Table(value = "service")
public class Service implements …Run Code Online (Sandbox Code Playgroud) java composite-key cassandra spring-data spring-data-cassandra