Annotation Interface TablePrimaryKeyClass
Marks a class as representing a composite primary key for a table entity.
This annotation is used to define a separate class that encapsulates the primary key
components (partition key + clustering columns) of a table. Fields within this class
should be annotated with PartitionBy and PartitionSort to define
the key structure.
This pattern is similar to Spring Data Cassandra's @PrimaryKeyClass 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: TYPE