I am using Cassandra 2.2.1. and I have a table job_status with the following key:
PRIMARY KEY (job_id, is_complete, last_run_at) WITH CLUSTERING ORDER BY (is_complete ASC, last_run_at DESC)
I have the following java class:
@Table(keyspace = "storakle", name = "import_job_status")
public class JobStatus
{
@PartitionKey
@Column(name = "job_id")
private String jobId;
@ClusteringColumn
@Column(name = "is_complete")
private boolean isComplete;
@ClusteringColumn
@Column(name = "last_run_at")
private Date lastRunAt;
@Column(name = "run_number_of_times")
private int runNumberOfTimes;
}
I would like to query my job_status table via the Mapper class in the Cassandra Java driver like this:
public JobStatus getIncompleteJobStatusById(String jobId)
{
Mapper<JobStatus> mapper = new MappingManager(_cassandraDatabaseManager.getSession()).mapper(JobStatus.class);
boolean isComplete = false;
JobStatus jobStatus = mapper.get(jobId, isComplete);
return jobStatus;
}
However I get the following error:
"Invalid ordering value 0 for annotation @ClusteringColumn of column lastRunAt, was expecting 1"
I can see why this is happening. The mapper gets all the primary and clustering keys that are annotated in the JobStatus class and checks upon the call to get whether the supplied keys in the mapper.get method are the same number as the keys in the annotated class.
But I thought in Cassandra it was possible to query a table without specifying all the clustering keys as long as the ones you omit are at the end?
Should I not use the Mapper in this case?