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!
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.