2009-08-03 22 views

回答

83

你的問題有點不清楚。假定「分類」是根實體和「2,3」是IDS(或種類的某些屬性的值「),您可以使用以下排除它們。

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

同樣可以用DetachedCriteria

+0

It works ... Thanks ChssPly76 .. – Shashi 2009-08-04 13:50:27

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(); 
相關問題