ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 离线条件查询 只有QBC支持. 它可以将dao层的所有判断放在web层来处理.它可以脱离session来执行. ~~~ //web层 DetachedCriteria dc = DetachedCriteria.forClass(Customer.class); //接收页面操作添加条件 dc.add(Restrictions.like("name", "%jack%")); //将dc对象传到service层,service层再传到dao层 //dao层 SessionFactory sessionFactory = Hibernate.getSessionFactory(); Session currentSession = sessionFactory.getCurrentSession(); Transaction tx = currentSession.beginTransaction(); //离线转在线 Criteria executableCriteria = dc.getExecutableCriteria(session); List<Customer> list = executableCriteria.list(); for (Customer c : list) { //TODO } tx.commit(); session.close(); ~~~