问题
I am using AWS Elasticache and here is the method I am using with annotation,
@Cacheable(unless = "#result != null and #result.size() == 0")
public List<SomeObject> findById(String id) {
return dynamoDBMapper.query(SomeObject.class, queryExpression(id));
}
Here is my query expression,
DynamoDBQueryExpression<SomeObject> queryExpression(String id) {
SomeObject object = new SomeObject();
object.setId(id);
return new DynamoDBQueryExpression<SomeObject>()
.withIndexName("idIndex")
.withConsistentRead(false)
.withHashKeyValues(object)
.withLimit(Integer.MAX_VALUE);
}
I keep on getting this error in my application log,
java.io.NotSerializableException: com.amazonaws.services.dynamodbv2.datamodeling.PaginatedQueryList
Looks like it needs the PaginatedQueryList class as Serializable. Though I am trying to cache List, not sure how this PaginatedQueryList is coming into the picture.
Appreciate help!
回答1:
PaginatedQueryList is the concrete List implementation returned by Dynamodb's query method. You'll have to copy your results into a serializable implementation of List, like ArrayList.
来源:https://stackoverflow.com/questions/45495145/issue-with-caching-and-dynamo-db-combination