Support of DynamoDB for Spring Data

CAST supports DynamoDB via its com.castsoftware.nosqljava extension. Details about the support provided for Java with Spring Data source code is explained below.

Supported Client Libraries

Library Supported
DynamoDBCrudRepository ✔️
DynamoDBPagingAndSortingRepository ✔️

Supported Operations

Operations Scenario Method Supported
Insert Spring Framework org.springframework.data.repository.CrudRepository.save
org.springframework.data.repository.CrudRepository.saveAll
Insert Social SignIn org.socialsignin.spring.data.dynamodb.repository.DynamoDBCrudRepository.save
org.socialsignin.spring.data.dynamodb.repository.DynamoDBCrudRepository.saveAll
org.socialsignin.spring.data.dynamodb.repository.DynamoDBPagingAndSortingRepository.save
org.socialsignin.spring.data.dynamodb.repository.DynamoDBPagingAndSortingRepository.saveAll
Select Spring Framework org.springframework.data.repository.CrudRepository.existsById
org.springframework.data.repository.CrudRepository.findAll
org.springframework.data.repository.CrudRepository.findById
org.springframework.data.repository.PagingAndSortingRepository.findAll
Select Social SignIn org.socialsignin.spring.data.dynamodb.repository.DynamoDBCrudRepository.existsById
org.socialsignin.spring.data.dynamodb.repository.DynamoDBCrudRepository.findAll
org.socialsignin.spring.data.dynamodb.repository.DynamoDBCrudRepository.findById
org.socialsignin.spring.data.dynamodb.repository.DynamoDBPagingAndSortingRepository.existsById
org.socialsignin.spring.data.dynamodb.repository.DynamoDBPagingAndSortingRepository.findById
org.socialsignin.spring.data.dynamodb.repository.DynamoDBPagingAndSortingRepository.findAll
Delete Spring Framework org.springframework.data.repository.CrudRepository.delete
org.springframework.data.repository.CrudRepository.deleteById
org.springframework.data.repository.CrudRepository.deleteAllById
org.springframework.data.repository.CrudRepository.deleteAll
Delete Social SignIn org.socialsignin.spring.data.dynamodb.repository.DynamoDBCrudRepository.delete
org.socialsignin.spring.data.dynamodb.repository.DynamoDBCrudRepository.deleteById
org.socialsignin.spring.data.dynamodb.repository.DynamoDBCrudRepository.deleteAllById
org.socialsignin.spring.data.dynamodb.repository.DynamoDBCrudRepository.deleteAll
org.socialsignin.spring.data.dynamodb.repository.DynamoDBPagingAndSortingRepository.delete
org.socialsignin.spring.data.dynamodb.repository.DynamoDBPagingAndSortingRepository.deleteById
org.socialsignin.spring.data.dynamodb.repository.DynamoDBPagingAndSortingRepository.deleteAllById
org.socialsignin.spring.data.dynamodb.repository.DynamoDBPagingAndSortingRepository.deleteAll

Objects

Icon Description
Java_DynamoDB_Client
Java_DynamoDB_Table
Java_Unknown_DynamoDB_Client
Java_Unknown_DynamoDB_Table
Link type Source and destination of link Methods Supported
parentLink Between DynamoDB client object and DynamoDB table -
useInsertLink Between the caller Java Method objects and DynamoDB client save
saveAll
useSelectLink Between the caller Java Method objects and DynamoDB client existsById
findById
findAll
useDeleteLink Between the caller Java Method objects and DynamoDB client delete
deleteById
deleteAll
deleteAllById

What results can you expect?

Some example scenarios are shown below:

DynamoDB Client with Java Configuration

@Configuration
@EnableDynamoDBRepositories(basePackages = "com.javasampleapproach.dynamodb.repo")
public class DynamoDBConfig {

    @Value("${amazon.dynamodb.endpoint}")
    private String dBEndpoint;

    @Value("${amazon.aws.accesskey}")
    private String accessKey;

    @Value("${amazon.aws.secretkey}")
    private String secretKey;

    @Bean
    public AmazonDynamoDB amazonDynamoDB() {
        AmazonDynamoDB dynamoDB = new AmazonDynamoDBClient(amazonAWSCredentials());

        if (!StringUtils.isNullOrEmpty(dBEndpoint)) {
            dynamoDB.setEndpoint(dBEndpoint);
        }

        return dynamoDB;
    }

    @Bean
    public AWSCredentials amazonAWSCredentials() {
        return new BasicAWSCredentials(accessKey, secretKey);
    }
}

Select Operation

public String findAll() {
        String result = "";
        Iterable<Customer> customers = repository.findAll();

        for (Customer cust : customers) {
            result += cust.toString() + "<br>";
        }

        return result;
    }

Insert Operation

public String save() {
        // save a single Customer
        repository.save(new Customer("JSA-1", "Jack", "Smith"));

}

Delete Operation

public String delete() {
        repository.delete(new Customer("JSA-1", "Jack", "Smith"));
        repository.deleteAll();
        return "Done";
    }

Known Limitations

  • Client is created as unknown, if the name is not retrieved from the properties file or if the name is not be resolved.