I have a table / entity on DynamoDB that should be mapped with number as fields.
Example:
@RegisterForReflection
Foo {
Integer myfield;
...
}
I noticed that the AWS SDK used by quarkus-amazon-dynamodb dependency is built in a odd way.
For example,the n() method of software.amazon.awssdk.services.dynamodb.model.AttributeValue
return a java String instead of a Number type, so I have to convert the result with a clumsy Integer.parseInt()
public static Foo from(Map<String, AttributeValue> item) {
final var output = new Foo();
if (item != null && !item.isEmpty()) {
output.setMyField(Integer.parseInt(item.get(MY_FIELD).n()));
}
return output;
}
The same happens if I have to fetch an item and use
AttributeValue.builder().n()
final Map<String, AttributeValue> key = new HashMap<>();
key.put(Foo.MY_FIELD, AttributeValue.builder().n(input.toString()).build()); // too bad!!
return GetItemRequest.builder()
.tableName(TABLE_NAME)
.key(key)
.attributesToGet(Foo.MY_FIELD)
.build();
Do I miss something ?
PS
The Quarkus dynamoDB documentation is here