Search code examples
javaspringspring-bootamazon-dynamodbdynamodb-queries

Can we use same DynamoDb table for two different java POJO classes


In my current java code, it has two different implementations for JSON Objects in two different POJOs. One of the pojo is using DynamoDBAtrribute annotation. I want that for another pojo class as well. Is it possible to use same DynamoTable for multiple POJOS?


Solution

  • Yes, you can do that and it will work fine, as long as they both use same key schema and you can ensure that you don’t try to read the 2nd type of records with the 1st POJO mapper and vice versa. DynamoDB itself does not care about schema (beyond hash/sort keys).