I have a query that I want to translate to Criteria API.
A query
select a, b, c from myTable t where t.e = ANY(?1)
After java processes it (native sql query) the final query looks like this
select a, b, c from myTable t where t.e = ANY(array['prop1', 'prop2', 'prop3'])
My Question is how to translate = ANY(?1)
part to Criteria API?
I see that any() definition is
public <Y> Expression<Y> any(Subquery<Y> subquery)
How to put array of values to it?
I'm using PostgreSQL
t.e = ANY(?)
and bind an array variable. JPQL simply does not support the syntax you're asking for. – Gleemanin (values)
is empty, that will result in a syntax error in the server side.x in ()
is invalid syntax, because it's expected that if your collection of values is empty that expression will always evaluate to false, which often means you can just skip or simplify the query. – Gleeman