Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with findBy..Contains on a set #282

Open
torstenzander opened this issue May 13, 2020 · 3 comments
Open

Problem with findBy..Contains on a set #282

torstenzander opened this issue May 13, 2020 · 3 comments

Comments

@torstenzander
Copy link

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:
@hannes-angst
Copy link

Fixed on boostchicken#34

@boostchicken
Copy link

Thanks to @hannes-angst this is now released in 5.2.5 under io.github.boostchicken

@mbissa
Copy link

mbissa commented Sep 22, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants