This is based on this repo: https://github.com/helloworldless/dynamodb-java-sdk-v2.
Here are the details of how we maintain isolation:
Repositoryinterface is public and is implemented by the package-private
Repositoryis defined in terms of public, database-agnostic value classes (in other words, nothing related to DynamoDB here)
DynamoDbRepositoryuses MapStruct to effortlessly convert the database-agnostic value classes into DynamoDB entities (
- The DynamoDB entities (
@DynamoDbBean) also live inside the repository package. They are public but should ideally be package-private. However, making them non-public would require switching to manually wiring the DynamoDB schema as opposed to using the SDK’s more convenient, annotation-driven schema capability.