I am testing DynamoDB tables and want to configure different table names for the prod and dev environment using the dev_ prefix for development.
I did this test to print the table name:
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig.TableNameOverride; TableNameOverride tbl = new TableNameOverride("test").withTableNamePrefix("dev_"); System.out.println("name=" + tbl.getTableName() + " prefix=" + tbl.getTableNamePrefix());
Fingerprints: name=null prefix=dev_
How come the name is null here?
TableNameOverride tbl = new TableNameOverride("test");//.withTableNamePrefix("dev_"); System.out.println("name=" + tbl.getTableName() + " prefix=" + tbl.getTableNamePrefix());
Fingerprints: name=test prefix=null
* How to get the table name as "dev_test"? *
I want to use this later to get the prefix "dev_" for all tables in design mode, for example:
DynamoDBTable annotation = (DynamoDBTable) myclass.getClass().getAnnotation(DynamoDBTable.class); TableNameOverride tbl = new TableNameOverride(annotation.tableName()).withTableNamePrefix("dev_");
Or is there another solution for sharing between dev and prod tables?
At first I thought about putting them in separate regions, but I'm not sure about that.
You can also use this:
mapper.save(ck, new DynamoDBMapperConfig(new TableNameOverride((isDev ? "dev_" : "") + annotation.tableName())));
java amazon-dynamodb
Guus
source share