Suppose you want to fetch a mobile list from mobileList table where mobile status is either 1 or 5 (in status column of mobileList table). We can fetch easily using Criteria Query and Restrictions API of Hibernate using OR Condition.
Here is the code:
final Integer status=1;
final Integer statusSec = 5;
final Session session=this.getSession();
final Criteria criteria=session.createCriteria(MobileList.class);
criteria.add(Restrictions.or(Restrictions.eq("status",status),
Restrictions.eq("status",statusSec)));
Reference:
http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/querycriteria.html
0 comments:
Post a Comment