• PUDN用户
    了解作者
  • Java
    开发工具
  • 7KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 6
    下载次数
  • 2010-04-12 14:28
    上传日期
hibernate3.0 的 Criteria使用指南 中文文档 是研究hibernate的必要指南
Criteria(hibernate3.0).rar
  • Criteria(hibernate3.0).doc
    48KB
内容介绍
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta name="generator" content="pdf2htmlEX"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css"> <link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css"> <link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/622b5a9115da9b288be78331/raw.css"> <script src="https://static.pudn.com/base/js/compatibility.min.js"></script> <script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script> <script> try{ pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({}); }catch(e){} </script> <title></title> </head> <body> <div id="sidebar" style="display: none"> <div id="outline"> </div> </div> <div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/622b5a9115da9b288be78331/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">Criteria<span class="_ _0"></span> <span class="_ _1"> </span> </div></div><div class="c x2 y3 w3 h4"><div class="t m0 x0 h3 y4 ff1 fs0 fc0 sc0 ls0 ws0"> <span class="_ _2"></span> <span class="_ _2"></span> <span class="_ _2"></span> </div></div><div class="c x0 y1 w2 h2"><div class="t m0 x3 h5 y2 ff2 fs0 fc0 sc1 ls0 ws0">&#20351;&#29992;&#25351;&#21335;<span class="_ _3"></span><span class="ff1 sc0"> <span class="_ _4"> </span> </span></div><div class="t m0 x1 h6 y5 ff2 fs1 fc1 sc0 ls0 ws0">&#32463;&#24120;&#29992;&#21040;<span class="_ _5"> </span><span class="ff3">Criteria,</span>&#25152;&#20197;&#20570;&#19968;&#19979;&#24635;&#32467;</div><div class="t m0 x1 h6 y6 ff3 fs1 fc1 sc0 ls0 ws0">&#58888;net.sf.hibernate.Criteria<span class="_ _5"> </span><span class="ff2">&#36825;&#20010;&#25509;&#21475;&#20195;&#34920;&#23545;&#19968;&#20010;&#29305;&#23450;&#30340;&#25345;&#20037;&#21270;&#31867;&#30340;&#26597;&#35810;&#12290;</span></div><div class="t m0 x1 h6 y7 ff3 fs1 fc1 sc0 ls0 ws0">Session<span class="_ _5"> </span><span class="ff2">&#26159;&#29992;&#26469;&#21046;&#36896;<span class="_ _5"> </span></span>Criteria<span class="_ _5"> </span><span class="ff2">&#23454;&#20363;&#30340;&#24037;&#21378;&#12290; </span></div><div class="t m0 x1 h7 y8 ff4 fs2 fc1 sc0 ls0 ws0">&#58881; </div><div class="t m0 x1 h8 y9 ff3 fs3 fc1 sc0 ls0 ws0">Criteria<span class="_ _6"> </span><span class="ff2">&#23545;<span class="_ _6"> </span></span>SQL<span class="_ _6"> </span><span class="ff2">&#36827;&#34892;&#23553;&#35013;&#65292;&#35753;&#24320;&#21457;&#20154;&#21592;&#21487;&#20197;&#29992;&#29289;&#20214;&#30340;&#26041;&#24335;&#26469;&#23545;&#36164;&#26009;&#24211;&#36827;&#34892;&#25805;&#20316;&#65292;&#20363;&#22914;&#19979;&#38754;&#30340;</span></div><div class="t m0 x1 h8 ya ff2 fs3 fc1 sc0 ls0 ws0">&#26597;&#35810;<span class="_ _6"> </span><span class="ff3">User<span class="_ _6"> </span></span>&#34920;&#26684;&#20013;&#30340;&#25152;&#26377;&#36164;&#26009;&#65306;</div><div class="t m0 x1 h9 yb ff5 fs3 fc1 sc0 ls0 ws0">Criteria criteria = session.createCriteria(User.class);</div><div class="t m0 x1 h8 yc ff5 fs3 fc1 sc0 ls0 ws0">// <span class="ff2 sc2">&#26597;&#35810;<span class="_ _6"> </span></span>user<span class="_ _6"> </span><span class="ff2 sc2">&#25152;&#26377;&#26639;&#20301;</span></div><div class="t m0 x1 h9 yd ff5 fs3 fc1 sc0 ls0 ws0">List users = criteria.list();</div><div class="t m0 x1 h9 ye ff5 fs3 fc1 sc0 ls0 ws0">Iterator iterator =&#58903; users.iterator();</div><div class="t m0 x1 h9 yf ff5 fs3 fc1 sc0 ls0 ws0">System.out.println("id name/age");</div><div class="t m0 x1 h9 y10 ff5 fs3 fc1 sc0 ls0 ws0">while(iterator.hasNext()) {</div><div class="t m0 x1 h9 y11 ff5 fs3 fc1 sc0 ls0 ws0">&#58903;&#58903;&#58903; User user = (User) iterator.next(); </div><div class="t m0 x1 h9 y12 ff5 fs3 fc1 sc0 ls0 ws0">&#58903;&#58903;&#58903; System.out.println(user.getId() +</div><div class="t m0 x1 h9 y13 ff5 fs3 fc1 sc0 ls0 ws0">&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903; " " + user.getName() +</div><div class="t m0 x1 h9 y14 ff5 fs3 fc1 sc0 ls0 ws0">&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903; "/" + user.getAge());&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903;&#58903; </div><div class="t m0 x1 h9 y15 ff5 fs3 fc1 sc0 ls0 ws0">}</div><div class="t m0 x1 h8 y16 ff3 fs3 fc1 sc0 ls0 ws0">Hibernate<span class="_ _6"> </span><span class="ff2">&#23454;&#38469;&#19978;&#20351;&#29992;&#20197;&#19979;&#30340;<span class="_ _6"> </span></span>SQL<span class="_ _6"> </span><span class="ff2">&#26469;&#26597;&#35810;&#36164;&#26009;&#24211;&#65306;</span></div><div class="t m0 x1 h9 y17 ff5 fs3 fc1 sc0 ls0 ws0">select this_.id as id0_, this_.name as name0_0_, this_.age as </div><div class="t m0 x1 h9 y18 ff5 fs3 fc1 sc0 ls0 ws0">age0_0_ from user this_</div><div class="t m0 x1 h8 y19 ff3 fs3 fc1 sc0 ls0 ws0">Criteria<span class="_ _6"> </span><span class="ff2">&#23454;&#38469;&#19978;&#21482;&#26159;&#20010;&#23481;&#22120;&#65292;&#22914;&#26524;&#24819;&#35201;&#35774;&#23450;&#26597;&#35810;&#26465;&#20214;&#65292;&#21017;&#35201;&#20351;&#29992;<span class="_ _6"> </span></span>add()<span class="ff2">&#26041;&#27861;&#21152;&#20837;</span></div><div class="t m0 x1 h8 y1a ff3 fs3 fc1 sc0 ls0 ws0">Restrictions<span class="_ _6"> </span><span class="ff2">&#30340;&#26465;&#20214;&#38480;&#21046;&#65292;&#20363;&#22914;&#26597;&#35810;<span class="_ _6"> </span></span>age<span class="_ _6"> </span><span class="ff2">&#22823;&#20110;<span class="_ _6"> </span></span>20<span class="_ _6"> </span><span class="ff2">&#19988;&#23567;&#20110;<span class="_ _7"> </span></span>40<span class="_ _7"> </span><span class="ff2">&#30340;&#36164;&#26009;&#65306;</span></div><div class="t m0 x1 h9 y1b ff5 fs3 fc1 sc0 ls0 ws0">Criteria criteria = session.createCriteria(User.class);</div><div class="t m0 x1 h9 y1c ff5 fs3 fc1 sc0 ls0 ws0">criteria.add(Restrictions.gt("age", new Integer(20)));</div><div class="t m0 x1 h9 y1d ff5 fs3 fc1 sc0 ls0 ws0">criteria.add(Restrictions.lt("age", new Integer(40)));</div><div class="t m0 x1 h9 y1e ff5 fs3 fc1 sc0 ls0 ws0">List users = criteria.list();</div><div class="t m0 x1 h8 y1f ff2 fs3 fc1 sc0 ls0 ws0">&#24744;&#20063;&#21487;&#20197;&#20351;&#29992;&#36923;&#36753;&#32452;&#21512;&#26469;&#36827;&#34892;&#26597;&#35810;&#65292;&#20363;&#22914;&#32467;&#21512;<span class="_ _7"> </span><span class="ff3">age<span class="_ _6"> </span></span>&#31561;&#20110;&#65288;<span class="ff3">eq</span>&#65289;<span class="ff3">20<span class="_ _6"> </span></span>&#25110;&#65288;<span class="ff3">or</span>&#65289;<span class="ff3">age<span class="_ _6"> </span></span>&#20026;&#31354;</div><div class="t m0 x1 h8 y20 ff2 fs3 fc1 sc0 ls0 ws0">&#65288;<span class="ff3">isNull</span>&#65289;&#30340;&#26465;&#20214;&#65306; </div><div class="t m0 x1 h9 y21 ff5 fs3 fc1 sc0 ls0 ws0">Criteria criteria = session.createCriteria(User.class);</div><div class="t m0 x1 h9 y22 ff5 fs3 fc1 sc0 ls0 ws0">criteria.add(Restrictions.or( </div><div class="t m0 x1 h9 y23 ff5 fs3 fc1 sc0 ls0 ws0">&#58903; &#58903; &#58903; &#58903; &#58903; &#58903; &#58903; &#58903; &#58903; &#58903;Restrictions.eq("age", new Integer(20)), </div><div class="t m0 x1 h9 y24 ff5 fs3 fc1 sc0 ls0 ws0">&#58903; &#58903; &#58903; &#58903; &#58903; &#58903; &#58903; &#58903; &#58903;&#58903; Restrictions.isNull("age") </div><div class="t m0 x1 h9 y25 ff5 fs3 fc1 sc0 ls0 ws0">&#58903; &#58903; &#58903; &#58903; &#58903; &#58903; &#58903; &#58903;)); </div><div class="t m0 x1 h9 y26 ff5 fs3 fc1 sc0 ls0 ws0">List users = criteria.list();</div><div class="t m0 x4 ha y27 ff3 fs3 fc1 sc0 ls0 ws0">&lt;script type="<span class="fc2 sc0">t</span><span class="fc2 sc0">e</span><span class="fc2 sc0">x</span><span class="fc2 sc0">t</span><span class="fc2 sc0">/</span><span class="fc2 sc0">j</span><span class="fc2 sc0">a</span><span class="fc2 sc0">v</span><span class="fc2 sc0">a</span><span class="fc2 sc0">scr</span><span class="fc2 sc0">i</span><span class="fc2 sc0">p</span><span class="fc2 sc0">t</span><span class="fc2 sc0">"&gt;</span><span class="fc2 sc0"> </span><span class="fc2 sc0">&lt;</span><span class="fc2 sc0">/</span><span class="fc2 sc0">scr</span><span class="fc2 sc0">i</span><span class="fc2 sc0">p</span><span class="fc2 sc0">t</span><span class="fc2 sc0">&gt;</span><span class="fc2 sc0">&lt;</span><span class="fc2 sc0">scr</span><span class="fc2 sc0">i</span><span class="fc2 sc0">p</span><span class="fc2 sc0">t</span></div><div class="t m0 x5 ha y28 ff3 fs3 fc1 sc0 ls0 ws0">src="http://pagead2<span class="fc2 sc0">.</span><span class="fc2 sc0">g</span><span class="fc2 sc0">o</span><span class="fc2 sc0">o</span><span class="fc2 sc0">g</span><span class="fc2 sc0">l</span><span class="fc2 sc0">e</span><span class="fc2 sc0">sy</span><span class="fc2 sc0">n</span><span class="fc2 sc0">d</span><span class="fc2 sc0">i</span><span class="fc2 sc0">ca</span><span class="fc2 sc0">t</span><span class="fc2 sc0">i</span><span class="fc2 sc0">o</span><span class="fc2 sc0">n</span><span class="fc2 sc0">.</span><span class="fc2 sc0">co</span><span class="fc2 sc0">m</span><span class="fc2 sc0">/</span><span class="fc2 sc0">p</span><span class="fc2 sc0">a</span><span class="fc2 sc0">g</span><span class="fc2 sc0">e</span><span class="fc2 sc0">a</span><span class="fc2 sc0">d</span><span class="fc2 sc0">/</span><span class="fc2 sc0">sh</span><span class="fc2 sc0">o</span><span class="fc2 sc0">w</span><span class="fc2 sc0">_a</span></div><div class="t m0 x6 ha y29 ff3 fs3 fc1 sc0 ls0 ws0">ds.js" type<span class="fc2 sc0">=</span><span class="fc2 sc0">"t</span><span class="fc2 sc0">e</span><span class="fc2 sc0">x</span><span class="fc2 sc0">t</span><span class="fc2 sc0">/</span><span class="fc2 sc0">j</span><span class="fc2 sc0">a</span><span class="fc2 sc0">v</span><span class="fc2 sc0">a</span><span class="fc2 sc0">scr</span><span class="fc2 sc0">i</span><span class="fc2 sc0">p</span><span class="fc2 sc0">t</span><span class="fc2 sc0">"&gt;</span><span class="fc2 sc0"> </span><span class="fc2 sc0">&lt;</span><span class="fc2 sc0">/</span><span class="fc2 sc0">scr</span><span class="fc2 sc0">i</span><span class="fc2 sc0">p</span><span class="fc2 sc0">t</span><span class="fc2 sc0">&gt;</span></div><div class="t m0 x4 ha y2a ff3 fs3 fc1 sc0 ls0 ws0">&lt;script type="<span class="fc2 sc0">t</span><span class="fc2 sc0">e</span><span class="fc2 sc0">x</span><span class="fc2 sc0">t</span><span class="fc2 sc0">/</span><span class="fc2 sc0">j</span><span class="fc2 sc0">a</span><span class="fc2 sc0">v</span><span class="fc2 sc0">a</span><span class="fc2 sc0">scr</span><span class="fc2 sc0">i</span><span class="fc2 sc0">p</span><span class="fc2 sc0">t</span><span class="fc2 sc0">"&gt;</span><span class="fc2 sc0"> </span><span class="fc2 sc0">&lt;</span><span class="fc2 sc0">/</span><span class="fc2 sc0">scr</span><span class="fc2 sc0">i</span><span class="fc2 sc0">p</span><span class="fc2 sc0">t</span><span class="fc2 sc0">&gt;</span><span class="fc2 sc0">&lt;</span><span class="fc2 sc0">scr</span><span class="fc2 sc0">i</span><span class="fc2 sc0">p</span><span class="fc2 sc0">t</span></div><div class="t m0 x5 ha y2b ff3 fs3 fc1 sc0 ls0 ws0">src="http://pagead2<span class="fc2 sc0">.</span><span class="fc2 sc0">g</span><span class="fc2 sc0">o</span><span class="fc2 sc0">o</span><span class="fc2 sc0">g</span><span class="fc2 sc0">l</span><span class="fc2 sc0">e</span><span class="fc2 sc0">sy</span><span class="fc2 sc0">n</span><span class="fc2 sc0">d</span><span class="fc2 sc0">i</span><span class="fc2 sc0">ca</span><span class="fc2 sc0">t</span><span class="fc2 sc0">i</span><span class="fc2 sc0">o</span><span class="fc2 sc0">n</span><span class="fc2 sc0">.</span><span class="fc2 sc0">co</span><span class="fc2 sc0">m</span><span class="fc2 sc0">/</span><span class="fc2 sc0">p</span><span class="fc2 sc0">a</span><span class="fc2 sc0">g</span><span class="fc2 sc0">e</span><span class="fc2 sc0">a</span><span class="fc2 sc0">d</span><span class="fc2 sc0">/</span><span class="fc2 sc0">sh</span><span class="fc2 sc0">o</span><span class="fc2 sc0">w</span><span class="fc2 sc0">_a</span></div><div class="t m0 x6 ha y2c ff3 fs3 fc1 sc0 ls0 ws0">ds.js" type<span class="fc2 sc0">=</span><span class="fc2 sc0">"t</span><span class="fc2 sc0">e</span><span class="fc2 sc0">x</span><span class="fc2 sc0">t</span><span class="fc2 sc0">/</span><span class="fc2 sc0">j</span><span class="fc2 sc0">a</span><span class="fc2 sc0">v</span><span class="fc2 sc0">a</span><span class="fc2 sc0">scr</span><span class="fc2 sc0">i</span><span class="fc2 sc0">p</span><span class="fc2 sc0">t</span><span class="fc2 sc0">"&gt;</span><span class="fc2 sc0"> </span><span class="fc2 sc0">&lt;</span><span class="fc2 sc0">/</span><span class="fc2 sc0">scr</span><span class="fc2 sc0">i</span><span class="fc2 sc0">p</span><span class="fc2 sc0">t</span><span class="fc2 sc0">&gt;</span></div></div><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a></div><div class="pi" data-data='{"ctm":[1.611850,0.000000,0.000000,1.611850,0.000000,0.000000]}'></div></div> </body> </html>
评论
    相关推荐
    • jsp中添加地图的shiro配置在maven项目中及demo示例
      java web项目开发添加地图的示例及代码,使用shiro配置地图权限,前段使用的jsp页面及maven的框架,代码可以直接应用到同类型项目。
    • 以shiro 权限来允许进入地图(google地图,阿里云地图)的访问示例
      以shiro 权限来允许进入地图(google地图,阿里云地图)的访问示例,确实很好的一个资源
    • ssh、ssm、maven项目模板
      ssh项目模板、ssm项目模板、spring+springmvc+hibernate+maven项目模板,纯净模板
    • BBS_system_on_java.rar
      BBS论坛系统由JAVA和JSP实现,开发中涉及JavaBean,JSP和服务器Tomcat5.0.7的设置,数据库用SQL2000。有注册登陆,浏览,发帖 回帖,帖子管理,论坛设置,管理版块,用户管理等模块。
    • 30184342396.rar
      jsp图书管理系统,自己看了,感觉还不错,用的mysql的数据库
    • online.rar
      jsp 在线客服 源码 实现在线聊天的功能
    • oa_09.rar
      oa办公系统 java+tomcat+mySQL实现
    • LibraryManage.rar
      是一个用jsp做前台,java做后台的图书管理系统,可供毕业设计做参考
    • demo.zip
      extjs与Struts整合以及与后台数据库的交互 非常值得学习的一个案例,仅供学习
    • exam.rar
      STRUTS的在线考试系统 数据库MYSQL 超完整,超好用的!