﻿{"id":134,"date":"2016-03-21T20:50:23","date_gmt":"2016-03-21T12:50:23","guid":{"rendered":"http:\/\/www.chenweikang.top\/?p=134"},"modified":"2016-03-21T22:03:23","modified_gmt":"2016-03-21T14:03:23","slug":"mybatis%e5%ad%a6%e4%b9%a0%e4%b9%8b%e8%b7%af-%e5%88%86%e9%a1%b5%e5%92%8c%e7%bc%93%e5%ad%98","status":"publish","type":"post","link":"https:\/\/www.chenweikang.top\/?p=134","title":{"rendered":"Mybatis\u5b66\u4e60\u4e4b\u8def\u2014\u5206\u9875\u548c\u7f13\u5b58"},"content":{"rendered":"<h2>\u4f7f\u7528mybatis\u5b9e\u73b0\u5206\u9875<\/h2>\n<h3>1.\u903b\u8f91\u5206\u9875 ( \u6570\u636e\u8868\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\u5206\u9875 )<\/h3>\n<blockquote>\n<p style=\"padding-left: 30px;\">&lt;!-- \u4f7f\u7528\u903b\u8f91\u5206\u9875<br \/>\n\u67e5\u8be2\u6240\u6709\u6570\u636e\u5230\u5185\u5b58<br \/>\nmybatis \u4f7f\u7528RowBounds\u8fdb\u884c\u5206\u9875<br \/>\n--&gt;<br \/>\n&lt;select id=\"findEmps1\" resultMap=\"empRes\" &gt;<\/p>\n<p style=\"padding-left: 60px;\">select * from employee<\/p>\n<p style=\"padding-left: 30px;\">&lt;\/select&gt;<\/p>\n<h3 style=\"padding-left: 30px;\">Junit\u4ee3\u7801<\/h3>\n<p style=\"padding-left: 30px;\">@Test<br \/>\npublic void testFindEmps1(){<\/p>\n<p style=\"padding-left: 60px;\">logger.info(\"\u903b\u8f91\u5206\u9875\uff1a\u67e5\u627e\u96c7\u5458!\");<\/p>\n<p style=\"padding-left: 60px;\">RowBounds rowBounds = new RowBounds(0, 4);<\/p>\n<p style=\"padding-left: 60px;\">List&lt;Employee&gt; emps= empMapper.findEmps1(rowBounds);<\/p>\n<p style=\"padding-left: 60px;\">for (Employee employee : emps) {<\/p>\n<p style=\"padding-left: 90px;\">System.out.println(employee);<\/p>\n<p style=\"padding-left: 60px;\">}<\/p>\n<p style=\"padding-left: 60px;\">sqlSession.commit();<\/p>\n<p style=\"padding-left: 30px;\">}<\/p>\n<\/blockquote>\n<h3>2.\u7269\u7406\u5206\u9875 (\u4f20\u9012\u53c2\u6570\u4f7f\u7528mysql\u7684limit\u5b9e\u73b0\u5206\u9875)<\/h3>\n<blockquote><p>&lt;!-- \u7269\u7406\u5206\u9875 --&gt;<br \/>\n&lt;select id=\"findEmps2\" resultMap=\"empRes\" parameterType=\"Map\"&gt;<br \/>\nselect * from employee<br \/>\n&lt;if test=\"start!=null and size!=null\"&gt;<br \/>\nlimit #{start},#{size}<br \/>\n&lt;\/if&gt;<br \/>\n&lt;\/select&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>\/\/\u7269\u7406\u5206\u9875\u6d4b\u8bd5<br \/>\n@Test<br \/>\npublic void testFindEmps2(){<\/p>\n<p style=\"padding-left: 30px;\">logger.info(\"\u7269\u7406\u5206\u9875\uff1a\u67e5\u627e\u96c7\u5458!\");<\/p>\n<p style=\"padding-left: 30px;\">Map&lt;String ,Object&gt; page = new HashMap&lt;&gt;();<\/p>\n<p style=\"padding-left: 30px;\">page.put(\"start\", 3);<\/p>\n<p style=\"padding-left: 30px;\">page.put(\"size\", 3);<\/p>\n<p style=\"padding-left: 30px;\">List&lt;Employee&gt; emps= empMapper.findEmps2(page);<\/p>\n<p style=\"padding-left: 60px;\">for (Employee employee : emps) {<\/p>\n<p style=\"padding-left: 90px;\">System.out.println(employee);<\/p>\n<p style=\"padding-left: 60px;\">}<\/p>\n<p style=\"padding-left: 30px;\">}<\/p>\n<\/blockquote>\n<p>&nbsp;<\/p>\n<h2>mybatis \u7f13\u5b58\u914d\u7f6e<\/h2>\n<h3>Mybatis\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u542f\u7528\u4e00\u7ea7\u7f13\u5b58 \uff0c<br \/>\n\u7528\u6237\u53ef\u4ee5\u81ea\u5df1\u914d\u7f6e\u4e8c\u7ea7\u7f13\u5b58(\u5168\u5c40)<br \/>\n\u9ed8\u8ba4\u60c5\u51b5\u4e0b select\u67e5\u8be2\u4f7f\u7528\u7f13\u5b58 ,insert,update,delete \u4e0d<br \/>\n\u4f7f\u7528\u7f13\u5b58<\/h3>\n<blockquote><p>\u53ef\u5728mepper\u4e2d\u914d\u7f6e\u7f13\u5b58<br \/>\n&lt;!--<br \/>\nsize=1024 :\u5b9a\u4e49\u7f13\u5b58\u5927\u5c0f \u9ed8\u8ba41024<br \/>\nflushInterval=\"60000\" : \u7f13\u5b58\u5237\u65b0\u5468\u671f ms<br \/>\neviction=\"LRU\" :\u7f13\u5b58\u79fb\u9664\u673a\u5236 LRU(\u6700\u8fd1\u6700\u5c11\u4f7f\u7528),\u8fd8\u6709FIFO<br \/>\nreadOnly=fase: \u7f13\u5b58\u53ef\u8bfb\u5199<br \/>\n--&gt;<br \/>\n&lt;cache size=\"1024\" flushInterval=\"60000\" eviction=\"LRU\" readOnly=\"false\" \/&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e5f\u53ef\u5728select update \u7b49\u6807\u7b7e\u4e2d\u4f7f\u7528 useCache \u6307\u5b9a<\/p>\n<p>&nbsp;<\/p><\/blockquote>\n<p>\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1a<a href=\"https:\/\/www.chenweikang.top\">\u5de6\u624b\u4ee3\u7801\u53f3\u624b\u8bd7<\/a> &raquo; <a href=\"https:\/\/www.chenweikang.top\/?p=134\">Mybatis\u5b66\u4e60\u4e4b\u8def\u2014\u5206\u9875\u548c\u7f13\u5b58<\/a><\/p><div class=\"__youshang\">\r\n            <div id=\"__youshang_popup\" class=\"wechat popup\" style=\"display: none;\">\r\n                <div class=\"head\">~\u8c22\u8c22\u6253\u8d4f~<\/div>\r\n                <div class=\"qrcode\"><div class=\"qrcode-li wechat\" ><img src=\"https:\/\/www.chenweikang.top\/wp-content\/uploads\/2019\/07\/wexin.png\" \/><\/div><div class=\"qrcode-li alipay\" style=\"display:none;\"><img src=\"https:\/\/www.chenweikang.top\/wp-content\/uploads\/2019\/07\/ali-pay.png\" \/><\/div><div class=\"qrcode-li hongbao\" style=\"display:none;\"><img src=\"https:\/\/www.chenweikang.top\/wp-content\/uploads\/2019\/07\/ali-hongbao.png\" \/><\/div><\/div>\r\n                <ul class=\"platform\"><li class=\"icon-wechat active\" data-bg-color=\"#05af4e\" data-thanks=\"~\u8c22\u8c22\u6253\u8d4f~\"><\/li><li class=\"icon-alipay \" data-bg-color=\"#00a2ea\" data-thanks=\"~\u8c22\u8c22\u6253\u8d4f~\"><\/li><li class=\"icon-hongbao \" data-bg-color=\"#dd5746\" data-thanks=\"<p>\u626b\u7801\u9886\u7ea2\u5305<\/p><p style='margin-top: 24px;'>\uff08\u4f59\u989d\u5b9d\u652f\u4ed8\u65f6\u53ef\u62b5\u73b0\uff09<\/p>\"><\/li><\/ul>\r\n            <\/div>\r\n            <a href=\"javascript:void(0);\" id=\"__youshang_btn\">\u8d4f<\/a>\r\n        <\/div>","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528mybatis\u5b9e\u73b0\u5206\u9875 1.\u903b\u8f91\u5206\u9875 ( \u6570\u636e\u8868\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\u5206\u9875 ) &lt;!-- \u4f7f\u7528\u903b\u8f91\u5206\u9875 \u67e5\u8be2\u6240 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":138,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,3],"tags":[32],"class_list":["post-134","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-note","tag-mybatis"],"_links":{"self":[{"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=\/wp\/v2\/posts\/134","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=134"}],"version-history":[{"count":0,"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=\/wp\/v2\/posts\/134\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=\/wp\/v2\/media\/138"}],"wp:attachment":[{"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chenweikang.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}