我遇到的情況,我必須執行多個查詢(刪除和添加),所以我用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