'Invalid column type with Spring Repository and native query with WHERE IN
I'm trying to write a native query in Spring @Repository that uses a WHERE IN condition, but I can't figure out what syntax must be used.
I tried the following:
@Query(nativeQuery=true, value="select ext_id,count(*) from table where ext_id in (?1) group by ext_id")
List<Object[]> get(Collection<Long> extIdList);
And
List<Object[]> get(Collection<BigDecimal> extIdList);
But I keep having the error "Invalid column type".
If I switch to named parameters with where ext_id in (:ids) and
List<Object[]> get(@Param("ids") Collection<Long> extIdList);
I get the error "SQL Error: Missing IN or OUT parameter"
What's the proper way to have the above query executed?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
