When using a composite primary key for a Cassandra-mapped entity, it should be possible to define which column(s) should form the partition key and the order of columns in the partition and clustering key.
Maybe something like this:
{code} @Entity class OrderLine {
@EmbeddedId public OrderLinePk pk;
... } {code}
{code} @Embeddable class OrderLinePk {
@PartitionKey public long orderNo;
public short serialNo; } {code}
The primary key created in Cassandra would be (orderno, serialno) (the first column given is the partition key).
Or with a compound partition key:
{code} @Embeddable class OrderLinePk {
@PartitionKey(order=1) public String customer;
@PartitionKey(order=2) public long orderNo;
public short serialNo; } {code}
The primary key created in Cassandra would be ((customerno, orderno), serialno) (the columns in the first brackets form the partition key).
Similarly for {{@ClusteringKey(order=123 ) }} if there is more than one clustering key column.
Some useful resources:
* http://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling * http://stackoverflow.com/questions/24949676/difference-between-partition-key-composite-key-and-clustering-key-in-cassandra |
|