我创建了一个方法
@Query(nativeQuery = true, value = "SELECT * FROM public.product WHERE concat(reg_id, inn, kpp, country) " + "alc_volume) ILIKE %?1% ORDER BY array_position(array[?2], id)")
List<Product> searchByPatternOrderId(String pattern, Set<Long> ids, Pageable pageable);
hibernate 生成了代码
SELECT * FROM public.product
WHERE concat(reg_id, inn, kpp, country) ILIKE ?
ORDER BY array_position(array[(?, ?, ?)], id) limit ? offset ?
postgresql 返回语法错误。
我今天遇到了同样的问题,虽然我没有找到删除Paranetheses的方法,但我找到了一个解决方法,可以解决我的问题。
我没有传递
Collection
参数,而是传递了 CSV 字符串。array[?1]
替换为 string_to_array(?1, ',')