方法一:
@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();
}
方法二:
@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();
}
方法二:
- public ArrayList<T> EmptyBaia(){
- DetachedCriteria subconsulta = DetachedCriteria.forClass(Usuarios.class).setProjection(Property.forName("baia"));
- ArrayList<T> baia = (ArrayList<T>) this.session.createCriteria(this.classe).add(Property.forName("numero").notIn(subconsulta)).list();
- return baia;
- }
本文深入探讨了SQL查询的优化技巧与高级应用实例,包括使用事务管理、避免重复查询和提升查询效率的方法。

7959

被折叠的 条评论
为什么被折叠?



