java如何使用Hashmap的@DynamoDBAttribute<String,@DynamoDBDocument>
我知道可能有更干净的方法来存储这些数据,为了在处理遗留代码时保持理智,我跳过了这一部分
我想在DynamoDB中存储一个如下所示的对象:
@DynamoDBTable(tableName="TableName")
public class MyItem {
// DynamoDB Attributes
private String hashKey;
private String someAttribute;
private Map<String, Config> configs;
@DynamoDBHashKey(attributeName = "hash_key")
public String getHashKey() {
return this.hashKey;
}
public void setHashKey(String hashKey) {
this.hashKey = hashKey;
}
@DynamoDBAttribute(attributeName = "some_attribute")
public String getSomeAttribute() {
return this.someAttribute;
}
public void setSomeAttribute(String someAttribute ) {
this.someAttribute = someAttribute;
}
@DynamoDBAttribute(attributeName = "configs")
public Map<String, Config> getConfigs() {
return this.configs;
}
public void setConfigs(Map<String, Config> configs)
{
this.configs = configs;
}
}
有补习班
@DynamoDBDocument
public class Config {
private String field;
@DynamoDBAttribute(attributeName="field")
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
}
- 这样行吗李>
- 对于以下JSON,在DynamoDB中生成的条目是什么样子的:
{
"hash_key":"123",
"some_attribute":"attribute_value",
"a_config_key" : {
"field":"field_value"
}
}
共 (0) 个答案