[英]How to Ignore a JsonProperty to be stored in DynamoDB
Here is my POJO that I use to store in DynamoDB using DynamodbMapper这是我使用 DynamodbMapper 存储在 DynamoDB 中的 POJO
@DynamoDBTable(tableName = "Data")
// @JsonIgnoreProperties(value = { "content" })
public class Data {
@DynamoDBRangeKey(attributeName = "Url")
@DynamoDBAutoGeneratedKey
@JsonProperty("url")
private String url;
@DynamoDBHashKey(attributeName = "UserName")
@JsonProperty("userName")
private String userName;
@JsonProperty("title")
@DynamoDBAttribute(attributeName = "Title")
private String pasteTitle;
@JsonProperty("content")
private String content;
@JsonProperty("date")
@DynamoDBAttribute(attributeName = "Date")
private String date;
}
Every time I run DynamoDBMapper.save(data)
, it stores content
as well even if it does not have DynamoDBAttribute
annotation.每次我运行
DynamoDBMapper.save(data)
时,它也会存储content
,即使它没有DynamoDBAttribute
注释。 By using @JsonIgnoreProperties(value = { "content" })
it makes the value as null and does not store the content.通过使用
@JsonIgnoreProperties(value = { "content" })
它使值成为 null 并且不存储内容。 But I would like to store the content in S3 and not DynamoDB and hence looking for a way to ignore this in DynamoDBAttribute.但我想将内容存储在 S3 而不是 DynamoDB 中,因此寻找一种在 DynamoDBAttribute 中忽略它的方法。
You can use @DynamoDBIgnore
- AWS documentation您可以使用
@DynamoDBIgnore
- AWS 文档
In your example:在您的示例中:
@DynamoDbIgnore
public String getContent() {
return content;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.