I have created a table in DynamoDB from aws console. while writing code for it, I am not able to find how to declare a sort key which is associated to a partition key
Table: Employee
----------------------------------------------
deptId | Partition key
empId | sort key for deptId
creationDateTime | global secondary index
----------------------------------------------
Class Definition:
@DynamoDBTable(tableName = "Employee")
public class Employee {
// I have created deptId as partition key
@DynamoDBHashKey(attributeName = "deptId")
private String dept;
// I have created empId as sort key for deptId (partition key)
private String empId;
// I want to run search query on empId as well
@DynamoDBIndexHashKey(attributeName = "empId", globalSecondaryIndexName = "empId-index")
@DynamoDBIndexHashKey(attributeName = "creationDateTime", globalSecondaryIndexName = "creationDateTime-index")
private String creationDateTime;
}
My question is what annotation should I use and how before the declaration of empId, that will declare that empId is sort key for deptId (which is a partition key)
I have searched around and found that @DynamoDBIndexRangeKey should be used for that but that annotation does link a sort key with partition key
please help me with that, thanks in advance