[英]DynamoDB Storing/ Mapping Complex Objects in Maps
We are trying to get started with dynamo db and I'm breaking my head over a mapping problem. 我们正在尝试开始使用dynamo db,而我在解决映射问题时不知所措。
I have a model Match and matchPlayer. 我有一个模型Match和matchPlayer。
Match has a map property which contains matchPlayer objects. Match具有一个包含matchPlayer对象的map属性。
I can't get dynamodb to correctly map this property. 我无法使dynamodb正确映射此属性。 I tried the json Marshaller but that just results into an error
我尝试了JSON Marshaller,但这只会导致错误
Expected S in value {M: {player2={M:(More json) 预期的S值{M:{player2 = {M :(更多json)
Are there any good examples or tutorials for mapping/ marshalling a map with complex objects to work with dynamodb? 是否有用于映射/编组具有复杂对象的地图以使用dynamodb的良好示例或教程? I found tutorials for working with simple complex objects but not with a map of objects.
我找到了用于处理简单复杂对象而不是对象图的教程。
I'm glad for any help! 我很高兴为您提供任何帮助!
@DynamoDBTable(tableName="Matches")
public class Match {
private String matchId;
private Boolean active;
private int currentRound;
private Boolean finished;
private Map<String, MatchPlayers> players;
@DynamoDBHashKey(attributeName = "matchId")
public String getMatchId() {
return matchId;
}
public void setMatchId(String matchId) {
this.matchId = matchId;
}
@DynamoDBIndexRangeKey(attributeName = "active")
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
}
@DynamoDBIndexRangeKey(attributeName = "currentRound")
public int getCurrentRound() {
return currentRound;
}
public void setCurrentRound(int currentRound) {
this.currentRound = currentRound;
}
@DynamoDBIndexRangeKey(attributeName = "finished")
public Boolean getFinished() {
return finished;
}
public void setFinished(Boolean finished) {
this.finished = finished;
}
@DynamoDBMarshalling(marshallerClass = MatchPlayersMarshaller.class)
@DynamoDBIndexRangeKey(attributeName = "players")
public Map<String, MatchPlayers> getPlayers() {
return players;
}
public void setPlayers(Map<String, MatchPlayers> players) {
this.players = players;
}
}
The DynamoDB Object Mapper for Android currently does not support complex data type mapping for the array and map. Android的DynamoDB对象映射器当前不支持数组和映射的复杂数据类型映射。 You need to manually map a dictionary to a custom object for yourself.
您需要自己将字典手动映射到自定义对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.