Reputation: 276
With a custom Marshaller
I try to map a DynamoDB query to an object
class ownObject {
private int myInteger;
@DynamoDBMarshalling(marshallerClass = MasrshallAsInteger.class)
@DynamoDBAttribute
public int getMyInteger {
return myInteger;
}
public void setMyInteger(int newint) {
myInteger = newint;
}
}
Since the value myInteger
in the db has both types String
and Number
, the SDK throws the Exception: "Expected S in value {N:123,}" if I use the marshaller and "Expected N in value {S:123,}" on an other object if I don't .
Is there any way to force the DynamoDB to use a custom marshaller and parse the value of the Key as String? Or is there any other way to parse a undetermined type of data but using PaginatedQueryList
?
Upvotes: 1
Views: 333
Reputation: 5205
I recommend you use the Document SDK to paginate, parse your items into Item objects, paginate, and then convert those Items to your domain.
Table table = new AmazonDynamoDBClient(new DefaultCredentialsProviderChain()).getTable("ownObject");
for (Item item : table.scan()) {
//convert item to your domain object here
}
Upvotes: 1