2009-08-03 19 views

Odpowiedz

83

Twoje pytanie jest nieco niejasne. Zakładając, „Kategoria” to jednostka korzeń i „2,3” są identyfikatory (lub wartości niektórych właściwości kategorii ") można wykluczyć je stosując następujący:.

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}) 
) 
); 

samo można zrobić z DetachedCriteria

+0

Działa ... Dzięki ChssPly76 .. – Shashi

1
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<RoomMaster> roomMasters=criteria.list();