Criteria is not in

Hey guys hope someone can help me out here, I seem to be not getting this. I have a list of id’s that I want to then retrieve records but ignore returning anything in that list.

I thought something like this but this throws an error.

criteria.isNot( criteria.restrictions.isIn(‘commentID’, interceptData.commentID) );

Anyone know what I should be doing here?

What’s the error? I’ve found that sometimes I need to javacast each item in the list to the correct type before passing the list to isIn().

yeah it did throw something like that.

java.lang.String cannot be cast to java.lang.Integer

That’s the error I got in my test too. Just cast the list items to int first, and it should work as the syntax you have is correct.

Yeah I nutted it down to this which works

criteria.isNot( criteria.restrictions.isIn(‘commentID’, javaCast(“java.lang.Integer[]”, listToArray(interceptData.commentID) )) );

The error message was throwing me as it stated int[] was acceptable, except it would throw an error still. So I saw this used somewhere and it seems to work.

Now I just need to throw a distinct in there, wish me luck :slight_smile:

Lol, i was just in the middle of typing the array method as well…glad it’s working

thanks, distinct was a piece of cake as well…