Annotation Interface TablePrimaryKey
Marks a field as containing the primary key for a table entity.
This annotation is used on a field whose type is annotated with TablePrimaryKeyClass.
The primary key class encapsulates all partition key and clustering column components.
This pattern is similar to Spring Data Cassandra's @PrimaryKey annotation and allows
for cleaner entity modeling when dealing with composite keys.
Usage Example:
@TablePrimaryKeyClass
public class OrderKey {
@PartitionBy(1)
@Column("customer_id")
private String customerId;
@PartitionSort(position = 1, order = PartitionSortOrder.ASC)
@Column("order_date")
private LocalDate orderDate;
// constructors, getters, setters, equals, hashCode
}
@EntityTable("orders")
public class Order {
@TablePrimaryKey
private OrderKey key;
@Column("amount")
private BigDecimal amount;
// getters and setters
}
Retention: RUNTIME
Target: FIELD