悠然哈哈哈

导航

2013年7月9日 #

Criteria查询

摘要: 1、Criteria表达式 Criteria c=session.createCriteria(User.class); List result=c.list(); Iterator it=result.iterator(); while(it.hasNext()){ User u=it.next(); System.out.println("用户名:"+u.getName()); } Criteria criteria = session.createCriteria(User.class); criteria.add(Restrictions.eq("name 阅读全文

posted @ 2013-07-09 18:48 悠然886 阅读(720) 评论(0) 推荐(0) 编辑

HQL进阶

摘要: 1、HQL查询性能优化 1.1、避免or操作 1.1.1、where子句包含or操作,执行时不使用索引 from Hose where street_id='1000' or street_id='1001' 1.1.2、可以使用in条件来替换 from Hose where street_id in('1000','1001') 1.2、避免使用not 1.2.1、where子句包含not关键字,执行时该字段的索引失效 from Hose h where not(h.price>1800) 1.2.2、使用比较运算符替换n 阅读全文

posted @ 2013-07-09 17:50 悠然886 阅读(328) 评论(0) 推荐(0) 编辑