0

How to pass list of ids to query.

List<Long> ids;
...
client.preparedQuery("SELECT id, name FROM features WHERE id IN $1").execute(Tuple.of(ids))

When I passed this query an error occurred saying invalid syntax near IN

Davide D'Alto
  • 7,421
  • 2
  • 16
  • 30
f3lngb4d
  • 3
  • 2

1 Answers1

0

You have to use the ANY operator:

client.preparedQuery("SELECT id, name FROM fruits WHERE id = ANY($1)")
                .execute(Tuple.of(ids.toArray(new Long[ids.size()])));

With IN operator one has to specify each parameter, with the ANY you can pass an array.

Davide D'Alto
  • 7,421
  • 2
  • 16
  • 30