I have list of category. I need a list of category by excluding 2,3 row. Can we achieve through hibernate by using Criteria and Restriction?
views:
2443answers:
2
                +4 
                A: 
                
                
              Your question is somewhat unclear. Assuming "Category" is a root entity and "2,3" are ids (or values of some property of the category") you can exclude them using the following:
Criteria criteria = ...; // obtain criteria from somewhere, like session.createCriteria() 
criteria.add(
  Restrictions.not(
     // replace "id" below with property name, depending on what you're filtering against
    Restrictions.in("id", new long[] {2, 3})
  )
);
Same can be done with DetachedCriteria.     
                  ChssPly76
                   2009-08-03 17:07:34
                
              It works... Thanks ChssPly76..
                  Shashi Bhushan
                   2009-08-04 13:50:27
                
                
                A: 
                
                
              
            Session session=(Session) getEntityManager().getDelegate(); Criteria criteria=session.createCriteria(RoomMaster.class); //restriction used or inner restriction ... criteria.add(Restrictions.not(Restrictions.in("roomNumber",new String[] { "GA8", "GA7"}))); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); List roomMasters=criteria.list();
                  sourav
                   2010-05-19 05:46:57