derjust / spring-data-dynamodb

This module deals with enhanced support for a data access layer built on AWS DynamoDB.
https://derjust.github.io/spring-data-dynamodb/
Apache License 2.0
403 stars 141 forks source link

DynamoDBMapperConfig is ignored (when specifying strong consistency) #221

Open Richrocksmy opened 6 years ago

Richrocksmy commented 6 years ago

Expected Behavior

When specifying DynamoDBMapperConfig bean as follows, it should be used by repository classes.


  public DynamoDBMapperConfig dynamoDBMapperConfig() {
    return DynamoDBMapperConfig.builder().withConsistentReads(CONSISTENT).build();
  }

## Actual Behavior
Bean is ignored and default config is applied (without strong consistency).

## Steps to Reproduce the Problem

  1. Create DynamoDBMapperConfig bean -

```@Bean
  public DynamoDBMapperConfig dynamoDBMapperConfig() {
    return DynamoDBMapperConfig.builder().withConsistentReads(CONSISTENT).build();
  }

2. Note that dynamo mapper config is null / uses default

## Specifications

  - Spring Data DynamoDB Version: 5.0.2 (2.0)
  - Spring Data Version:  2.0.5.RELEASE
  - AWS SDK Version: 1.11.445
  - Java Version: 1.8.0_151
  - Platform Details: Mac OS X 10.12.6

All those information are logged by `org.socialsignin.spring.data.dynamodb.repository.support.DynamoDBRepositoryFactory` on `INFO` level on startup.
Or use `java -version` and `mvn dependency:tree | grep -E 'spring|aws'` to provide those version numbers.
derjust commented 6 years ago

As part of the @EnableDynamoDBRepositories() the bean name of the mapper configuration must be specified. For this example it should look like this:

@EnableDynamoDBRepositories(
dynamoDBMapperConfigRef="dynamoDBMapperConfig" //must be the actual bean name
)

Same pattern as described in this article