I have a table like:
Users (user_id, name, age, country_id)
Now I want a query like:
SELECT *
FROM users
where country_id in (1,2,3,4,5)
There are no relationships for the user, I just want to do this without any associations.
I want to do this with Criteria query.
I see restrictions, but not sure if it has a where in clause:
sessionFactory.getCurrentSession().createCriteria(User.class)
.add(Restrictions.eq("country_id", countryId)
.list();
So my change is that I have a list of country ids (List countryIds) that I need to pass.
Do you want ‘country_id in (…)’?
If yes, then:
Also I used “countryId” – as in criteria you use property names, not table column names.