I have one variable like long[] ids = [10, 11]
and I am trying to fire query like this :
Query query2 = session.createQuery("update Employee e SET e.isLatest = false where e.id not in (:ids)");
query2.setParameter("ids", ids);
query2.executeUpdate();
But I am getting error like
org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint <> character varying
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
How can pass array variable in NOT IN
parameter? Or Is there any other way for handling such query ?
Try
query2.setParameterList("ids", ids);
There are two ways
1) use of setParameterList(,);
and pass collection
2) Use
query2.setParameter("ids", ids);
where ids
is one string , which contains comma separated id
eg.
String commaseperatedId="10,11".
and then
query2.setParameter("ids", commaseperatedId);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With