Below query is wokring in postgres SQL and giving required result, but when trying from JAVA it is giving error.
select * from res where
'{"^\\d{3}\\d{1,}133\\d{1,}$","^\\d{3}7483"}' is null
or exists (select from unnest(cast('{"^\\d{3}\\d{1,}133\\d{1,}$","^\\d{3}7483"}' as text[])) rx where cast (r.res_value as text) ~ rx);
java code:-
@Query(value = "select * from res where
'{?1 is null
or exists (select from unnest(cast(?1 as text[])) rx where cast (r.res_value as text) ~ rx)",nativeQuery = true)
public List<Res> getData(List<String> patterns);
List of patterns =
^\\d{3}\\d{1,}133\\d{1,}$
^\\d{3}7483
Error getting - "ERROR: malformed array literal: ^\d{3}\d{1,}133\d{1,}$ Detail: Array value must start with "{" or dimension information.
How i can add { } to these.. any solution in JPA