michaellavelle / spring-data-dynamodb

Simplifies the development of creating an Amazon DynamoDB-based Java data access layer
https://derjust.github.io/spring-data-dynamodb/
Apache License 2.0
169 stars 284 forks source link

deleteAll() throws DynamoDBMappingException #34

Closed treidel closed 9 years ago

treidel commented 10 years ago

Using 1.0.1.SNAPSHOT version of spring-data-dynamodb. It appears that calling deleteAll() on a repository goes down an unintentional codepath. DynamoDBTemplate.batchDelete() is passed a PaginatedScanList object by SimpleDynamoDBCrudRepository.deleteAll().

Here is the exception raised: com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMappingException: Class class com.amazonaws.services.dynamodbv2.datamodeling.PaginatedScanList must be annotated with interface

Instead of invoking DynamoDBMapper.batchDelete(List) the wrong version of this function (DynamoDBMapper.batchDelete(Object...) ) is invoked. The result is later on DynamoDBReflector.getTable() is passed the PaginatedScanList class instead of the domain object class. The result is the exception which should not be seen here.

DynamoDBReflector.getTable(Class) line: 190
DynamoDBMapper.getTableName(Class<?>, DynamoDBMapperConfig, DynamoDBReflector) line: 551
DynamoDBMapper.getTableName(Class<?>, DynamoDBMapperConfig) line: 544
DynamoDBMapper.batchWrite(List, List, DynamoDBMapperConfig) line: 1516
DynamoDBMapper.batchDelete(Object...) line: 1393
DynamoDBTemplate.batchDelete(Iterable<?>) line: 164 DeviceRepositoryImpl(SimpleDynamoDBCrudRepository<T,ID>).deleteAll() line: 218

I'll submit a pull request with a fix in a little while.

michaellavelle commented 9 years ago

Fixed - many thanks.