Expected Behavior
Repository perform a query over a method that only uses hashKey and rangeKey attributes, and result this:
"{"TableName":"music","KeyConditionExpression":"artist = :_artist and begins_with(title, :_title)","ExpressionAttributeValues":{":_artist":{"S":"Djavan"},":_title":{"S":"Eu te devoro"}}}"
Actual Behavior
Repository perform a scanFilter over a method that only uses hashKey and rangeKey attributes, and result this:
"{"TableName":"music","ScanFilter":{"artist":{"AttributeValueList":[{"S":"Djavan"}],"ComparisonOperator":"EQ"},"title":{"AttributeValueList":[{"S":"Eu te devoro"}],"ComparisonOperator":"BEGINS_WITH"}}}"
Steps to Reproduce the Problem
Using a entity named Music
@DynamoDBTable(tableName = "music")
data class Music(
@field:Id
@DynamoDBIgnore
val id: MusicId = MusicId(),
var genre: String? = null
) {
@DynamoDBHashKey(attributeName = "artist")
fun getArtist() = id.artist
fun setArtist(artist: String) {
id.artist = artist
}
@DynamoDBHashKey(attributeName = "title")
fun getTitle() = id.title
fun setTitle(title: String) {
id.title = title
}
}
@DynamoDBDocument
data class MusicId(
@field:DynamoDBHashKey(attributeName = "artist")
var artist: String? = null,
@field:DynamoDBRangeKey(attributeName = "title")
var title: String? = null
) : Serializable
And a repository
@EnableScan //I know that if I remove this annotation, enables won't be permitted, but the problem is that the implementation code doesn't recognize my method as a key query and if I remove this annotation, the method falls on invocation
interface MusicRepository : CrudRepository<Music, MusicId> {
fun findByArtistAndTitleStartingWith(artista: String, sortKey: String): List<Music>
}
And when i invoke:
@PostConstruct
fun init() {
println(musicRepository.findByArtistAndTitleStartingWith("Djavan", "Eu te devoro").joinToString())
}
the log show's me the call to AWS as i showed above
Specifications
- Lib: https://github.com/boostchicken/spring-data-dynamodb
- Spring Data DynamoDB Version: 5.2.5
- Spring Data Version: Doesn't used
- Spring Boot Starter Web Version: 2.3.4.RELEASE
- AWS SDK Version: 1.11.573
- Java Version: 11
- Platform Details: Windows
did I something wrong? Or is the other approach that spring data create the correct query to aws?