spring-data-dynamodb
spring-data-dynamodb copied to clipboard
Problem with findBy..Contains on a set
Expected Behavior
I have a method findByPostsContainingAndPublished(String slug, Booolean ispublished) this should look for a string in a Set.
For my understanding this should work, looking for a string in the set
Actual Behavior
I get:
class java.lang.String cannot be cast to class java.util.Collection (java.lang.String and java.util.Collection are in module java.base of loader 'bootstrap') java.lang.ClassCastException: class java.lang.String cannot be cast to class java.util.Collection (java.lang.String and java.util.Collection are in module java.base of loader 'bootstrap') at com.amazonaws.services.dynamodbv2.datamodeling.StandardTypeConverters$Vector$ToSet$1.convert(StandardTypeConverters.java:449) at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTypeConverter$DelegateConverter.convert(DynamoDBTypeConverter.java:104) at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTypeConverter$NullSafeConverter.convert(DynamoDBTypeConverter.java:123) at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTypeConverter$ExtendedConverter.convert(DynamoDBTypeConverter.java:83) at com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperFieldModel.convert(DynamoDBMapperFieldModel.java:138)
My Model:
@DynamoDBTable(tableName = "products")
public class Product {
private Set<String> posts;
public Set<String> getPosts() {
return posts;
}
public void setPosts(Set<String> posts) {
this.posts = posts;
}
}
And my repository method:
List<Product> findByPostsContainingAndPublished(String slug, Boolean published);
Specifications
- Spring Data DynamoDB Version: 5.1.0
- Spring Data Version: 2.2.6
- AWS SDK Version: 1.11.774
- Java Version: 12
- Platform Details:
Fixed on https://github.com/boostchicken/spring-data-dynamodb/pull/34
Thanks to @hannes-angst this is now released in 5.2.5 under io.github.boostchicken
I am facing a similar issue with Lists
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List
my method name is: findPaymentsByOrdersContaining I am not able to find a solution for this - can you point me to the right direction please?