我遇到的情况,我必须执行多个查询(删除和添加),所以我用dynamoDB的交易库,但我收到序列化错误。我称为此URL作为一个例子 http://aws.amazon.com/blogs/aws/dynamodb-transaction-library/dynamoDB事务管理
下面是我的代码:
DynamoDBScanExpression scanExpression =新DynamoDBScanExpression(); PaginatedScanList financeIndex = mapper.scan(FinanceIndex.class,scanExpression); String index,index1 = null;
AWSCredentials credentials = Application.getCredentials();
AmazonDynamoDB client = new AmazonDynamoDBClient(credentials);
TransactionManager manager = new TransactionManager(client, "Transactions", "TransactionImages");
TransactionManager.verifyOrCreateTransactionTable(client, "Transactions", new Long(10) , new Long(10), new Long(1060));
TransactionManager.verifyOrCreateTransactionImagesTable(client, "TransactionImages", new Long(10), new Long(10), new Long(1060));
for (FinanceIndex financeID : financeIndex) {
index1 = financeID.getID();
Transaction t1 = manager.newTransaction();
Map<String, AttributeValue> reply1 = new HashMap<String, AttributeValue>();
reply1.put("id", new AttributeValue(index1));
t1.deleteItem(new DeleteItemRequest().withTableName("FinanceIndex").withKey(reply1));
//mapper.delete(financeID);
int id = Integer.valueOf(index1);
id = id + 1;
index = String.valueOf(id);
financeID.setID(index);
//mapper.save(financeID);
Map<String, AttributeValue> reply2 = new HashMap<String, AttributeValue>();
reply2.put("id", new AttributeValue(financeID.getID()));
t1.putItem((new PutItemRequest().withTableName("FinanceIndex").withItem(reply2)));
t1.commit();
}
return index1;
我得到以下错误:
com.amazonaws.services.dynamodbv2.transactions.exceptions.TransactionAssertionException:d1c3bb93-e9b7-4052-B328-b357ab412a3a - 无法序列化要求com.amazonaws.services。 [email protected] com.fasterxml.jackson.databind.JsonMappingException:未找到类com.amazonaws.event.ProgressListener $ 1串并没有发现创建BeanSerializer性(避免异常,禁用SerializationConfig.SerializationFeature.FAIL_ON_EMPTY_BEANS ))(通过引用链:com.amazonaws.services.dynamodbv2.transactions.DeleteItem [“request”] - > com.amazonaws.services.dynamodbv2.model.DeleteItem请求[“generalProgressListener”])
谁能告诉我什么我做错了什么? 在此先感谢。
请添加mapper的定义。另外,不在黑暗来源区域的少数几条首行也难以阅读。什么是SDK版本? – 2014-09-07 19:26:07
mapper的定义:protected static DynamoDBMapper mapper; SDK版本是1.8。 – user3334226 2014-09-08 18:36:29