Closed
Description
Expected Behavior
I'm working on a Kotlin program and a table I'm writing a crud repository for uses both a hash and range key. After consulting this page:
https://github.com/derjust/spring-data-dynamodb/wiki/Use-Hash-Range-keys
I've written what I believe to be the Kotlin equivalent of the necessary code. As such I would expect the code to compile with no errors.
Actual Behavior
Attempting to save an entry to the table produces this exception:
com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: One of the required keys was not given a value
Steps to Reproduce the Problem
Here are the relevant sections of the code:
interface FoobarRepository: CrudRepository<FoobarEntry, FoobarEntryId> {
fun findAllByFoobarCode(foobarCode: String): Iterable<FoobarEntry>
}
data class FoobarEntryId (
@get:DynamoDBHashKey var foobarCode: String? = null,
@get:DynamoDBRangeKey var foobarKey: String? = null
)
@DynamoDBTable(tableName = "Foobars")
class FoobarEntry(
@Id
private var foobarEntryId: FoobarEntryId? = null,
@get:DynamoDBHashKey
@get:DynamoDBAttribute
var foobarCode: String? = null,
@get:DynamoDBRangeKey
@get:DynamoDBAttribute
var foobarKey: String? = null,
@get:DynamoDBAttribute
var foobarValue: String? = null
)
@Component
class LocalDatabase(
val foobarRepository: FoobarRepository
) {
@PostConstruct
fun start () {
setupTestData()
}
private fun setupTestData() {
foobarRepository.save(FoobarEntry(
foobarEntryId = FoobarEntryId(foobarCode = "1", foobarKey = "key"),
foobarCode = "1",
foobarKey = "key",
foobarValue = "value"
))
}
}
The exception occurs when trying to instantiate a LocalDatabase bean.
Specifications
- Spring Data DynamoDB Version: 5.1.0
- Spring Data Version: 2.1.2
- AWS SDK Version: 1.11.228
- Java Version: 1.8
- Platform Details: Mac
Metadata
Metadata
Assignees
Labels
No labels