Reputation: 2131
I have more than 1 table which follows the same data modeling structure. Basically, I have a different type of orders and based on its type, I am saving and retrieving orders from the tables based on their type.
Example :
All table have same data model.
Structure:
OrderID,Date...
I am using DynamoDbMapper. As DynamoDbMapper needs
@DynamoDBTable(tablename=TABLE)
annotation on class. How can I share this same model among all Order Tables?
@DynamoDBTable(tablename=TABLE)
public class Order{
public String orderID;
public String date;
}
Upvotes: 1
Views: 2317
Reputation: 7669
DynamoDBMapper allows you to provide some optional config, including overriding the table name.
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().build();
// In all cases, setting null tells DynamoDBMapper to use the default value
DynamoDBMapperConfig mapperConfig = new DynamoDBMapperConfig(
null, // Save behavior
null, //ConsistentReads
“TableName”, //TableNameOverride
null // PaginationLoadingStrategy
);
DynamoDBMapper mapper = new DynamoDBMapper(client, mapperConfig, cp);
You can also provide a DynamoDBMapperConfig on a per-operation basis.
See https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapper.OptionalConfig.html
Upvotes: 2