Closed ujjwal closed 4 years ago
Yes via AWS functionality itself:
@Configuration
@EnableDynamoDBRepositories(dynamoDBMapperConfigRef = "dynamoDBMapperConfig",
basePackages = "com.acme.repository")
public class DynamoDBConfig {
@Bean
public DynamoDBMapperConfig dynamoDBMapperConfig() {
DynamoDBMapperConfig.Builder builder = new DynamoDBMapperConfig.Builder();
builder.setTableNameResolver(new YourCustomTableNameResolverHere());
return builder.build();
}
}
If you just wan to prefix table names (to separate environments), there are ready-to go classes:
builder.setTableOverride(
com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig.TableNameOverride.withTableNamePrefix("dev"));
Please let us know if the provided answer helps your use case. Please use https://github.com/derjust/spring-data-dynamodb/issues/18 for followup comments.
As (privately) communicated with @michaellavelle, the project will continue under https://github.com/derjust/spring-data-dynamodb.
Not sure maybe it is the bug in AWS lib. I'm using "aws-java-sdk-bom" 1.11.175. The problem is when I use my own DynamoDBMapperConfig, then config.getTypeConverterFactory() is the null and internal error thrown.
I have added:
builder.setTypeConverterFactory(DynamoDBMapperConfig.DEFAULT.getTypeConverterFactory());
Is there a way to pass the tableName as a parameter?