hibernate3学习笔记(四) 增删改查 - 编程入门网
) {
63. User user = (User) iterator.next();
64. System.out.println(user.getId() + " \t " + user.getName() + "/" + user.getAge());
65. }
66.
67. session.close();
68. sessionFactory.close();
69. }
70.}
hibernate3学习笔记(四) 增删改查(3)时间:2011-02-01执行结果: 13:05:43,031 WARN ConfigurationFactory:127 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/Java/MyEclipse%206.0/workspace/hb3demo/ehcache-1.2.3.jar!/ehcache-failsafe.xml 13:05:43,453 WARN EhCacheProvider:93 - Could not find configuration [org.hibernate.cache.UpdateTimestampsCache]; using defaults. 13:05:43,484 WARN EhCacheProvider:93 - Could not find configuration [org.hibernate.cache.StandardQueryCache]; using defaults. Hibernate: select this_.id as id0_0_, this_.name as name0_0_, this_.age as age0_0_ from user this_ id name/age 1 shenbin/29 2 chenyan/24 3 chenyan/24 4 chenyan/24 Hibernate: select this_.id as id0_0_, this_.name as name0_0_, this_.age as age0_0_ from user this_ where this_.name=? id name/age 1 shenbin/29 ================================================ Hibernate: select user0_.id as id0_, user0_.name as name0_, user0_.age as age0_ from user user0_ id name/age 1 shenbin/29 2 chenyan/24 3 chenyan/24 4 chenyan/24 Hibernate: select user0_.id as id0_, user0_.name as name0_, user0_.age as age0_ from user user0_ where user0_.name like ? id name/age 1 shenbin/29 以上分别演示了使用Criteria对SQL的分装以及透过HQL来进行查询。 注意: 代码中如下部分 //criteria.add(Expression.eq("name", "shenbin")); criteria.add(Restrictions.eq("name", "shenbin")); 在hibernate3.3以后的版本,可能Expression类会被废除,为了保证代码的向后兼容,请使用Restrictions替代。 |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |