hibernate not in 查询条件为一个集合

hibernate not in 查询条件为一个集合【原创】

@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
public List<OpUsrrole> OpUsrroleExList(List<OpUsrrole> grprole) {
   ArrayList<Long> ids = new ArrayList<Long>();
   for(int i=0;i<grprole.size();i++){
    ids.add(grprole.get(i).getIRoleid());
    System.out.println(ids.get(i).toString());
   }
   Query q = sessionFactory.getCurrentSession().createQuery("select distinct rl from OpUsrrole rl where rl.IRoleid not in(:ids)");
   q.setParameterList("ids", ids);
   return q.list();
  
}

String+hibernate