I have a situation where
val someList: List<String> actually contains elements of a different type instead of only String. Is this normal ?
To elaborate: I’m using Spring Data JPA. I have a function with
@Query, that had a
List<String> as a return type. Because of a mistake I made in the query, instead of this function returning a
List<String> I ended up with a list containing
SomeEntity from calling this function.
It looked something like this:
@Query("bad query") fun findEntityNames(): List<String> ... val entityNames: List<String> = findEntityNames() // here entityNames actually contains List<SomeEntity> and not List<String>, still no exception
It kept working fine until I tried to use that value in a stream, then I got:
java.lang.IllegalArgumentException: Parameter value element <omitted> did not match expected type [java.lang.String (n/a)]
The rest of the stacktrace contains only hibernate references, nothing for Kotlin, but it seemed odd that I can declare a specific type for a value and it will be ignored.
When debugging, I saw the type of
entityNames was a raw
Did I do something wrong, or should I report this as a bug ?