Hello,
I am getting the exception below. org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [com.x.y.z.domain.prefix.OrderPrefix@842cfa72] did not match expected type [java.util.List (n/a)]; nested exception is java.lang.IllegalArgumentException: Parameter value [com.x.y.z.domain.prefix.OrderPrefix@842cfa72] did not match expected type [java.util.List (n/a)]
Basically I am converting Prefix list to string and writing to database as a string in a column. I can save successfully while I am using Spring Data JPA’s CrudRepository. However I have a custom update query which takes fields and manually updates and it looks like this.
After I pass a valid Entity object to this class, I am quite sure that I am passing a List object to prefixes field. However I keep getting the same exception over and over again. Actually when I turn the rollback off, i can see that it updates the result, however throws exception after execution.
Could you guys point me out where the mistake is? Thank you!
Thanks for your reply! I also want to confirm that my implementation logic doesn’t sound broken. Prefix is a custom interface and I am able to confirm that Converter class is able to de/serialise JSON to List and vice versa but it fails to do so with custom query. I also tried to use Spring Data’s entity manager object to build same query I built with @Query but it failed. I will try to use the test case that you provide to figure out whether that’s a Spring issue or not. Thank you!
I can confirm that I managed to create the same error with a different exception type using the test case you provided. This time I used entitymanager.createUpdate() and got this one. Thank you.
java.lang.IllegalArgumentException: Parameter value [com.x.y.z.PreOrderPrefix@842cfa72] did not match expected type [java.util.List (n/a)]
This will simply not work right now. We might be able to fix this for Hibernate 6.0 but right now, we simply interpret any collection as mutli-valued parameter value, because we don’t know for sure if a parameter allows a multi-valued value. As a workaround, you can bind the string.