1

I have next issue: I have list of names, based on which I want to filter.The problem is that I have not full names(Because I'm receiving them from ui), and I have, for example, this array= ['Joh', 'Michae'].

So, I want to filter based on this array.

I wrote query in PostgreSQL

select * from q_ob_person where name  like any (array['%Хомяченко%', '%Вартопуз%']);

And I want to ask how to write JPQL query gor this.

Is there an option to call postgresql function like any from JPQL?

1 Answer 1

2

JPA 2.1 allows invocation of any SQL function using

FUNCTION(sqlFuncName, sqlArgs)

So you could likely do something like (note never tried this LIKE ANY you refer to, just play around with it)

FUNCTION("LIKE", FUNCTION("ANY", arrayField))

Obviously by invoking SQL functions specific to a particular RDBMS you lose database independence (in case that's of importance).

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I will try to find more information about that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.