Reputation: 379
My Table structure is as follows:
Can someone help with the following criteria query:
Criteria c = getSession().createCriteria(getEntity(), "b");
c.add(Restrictions.in("b.isTwitterVerified", 1));
or // b.isFbVerified =1// something like this
return c.list();
Upvotes: 1
Views: 2221
Reputation: 26522
This should return what your after:
Criteria criteria = getSession().createCriteria(getEntity(), "b");
Criterion isTwitterVerified = Restrictions.eq("b.isTwitterVerified", 1);
Criterion isFbVerified = Restrictions.eq("b.isFbVerified ", 1);
criteria.add(Restrictions.or(isTwitterVerified , isFbVerified ));
return criteria.list();
On the side.. the in
restriction that you tried to use: Restrictions.in
.. this would have its place when you would like to verify a certain field against many values (1,3,5 for example).
Upvotes: 5