I am working with SpringBoot application that does CRUD operation on aws dynamoDB, and I have entity class that has structure of the following
// getter, setter, args, no args annotation here
@DynamoDBTable(tableName = "TableName")
public class Entity {
@DynamoDBHashKey(attributeName = "PartitionKey")
private String key;
@DynamoDBRangeKey(attributeName = "SortKey")
private String tempSortKey;
@DynamoDBAttribute(attributeName = "Value")
private String tempValue;
@DynamoDBAttribute(attributeName = "TerminationDate")
private Date tempTerminationDate;
// bunch of other variables and attributes
// Repository
public Entity savEntity(Entity entity) {
dynamoDBMapper.save(entity);
return entity;
}
// Controller
//Controller Class
@PostMapping(value="URL")
public Entity saveItem(@RequestBody Entity key) {
return Repository.saveKeyValue(key);
I get an error and the error message is: "Unable to unmarshall exception response with the unmarshallers provided (Service: AmazonDynamoDBvZ; Status Code: 400; Error Code: ValidationException".
I have made sure that PartitionKey is of type string and sort key is not selected when dynamoDB was first created and I do not have access to either create or modify the table. Other thing I tried was to change the entity class like so
// getter, setter, args, no args annotation here
@DynamoDBTable(tableName = "TableName")
public class Entity {
@DynamoDBHashKey(attributeName = "PartitionKey")
@DynamoDBAUtogeneratedKey
private String uniquekey;
@DynamoDBAttribute(attributeName="key")
private String key;
@DynamoDBRangeKey(attributeName = "SortKey")
private String tempSortKey;
@DynamoDBAttribute(attributeName = "Value")
private String tempValue;
@DynamoDBAttribute(attributeName = "TerminationDate")
private Date tempTerminationDate;
// bunch of other variables and attributes
This works fine but I do not want Autogenerated unique key. I also need Sort key within Table as key might have similar values but sort key will always have unique value.
I also tried having key on two different variable one as HashKey and one as Attribute and that works fine.
Thanks