{"id":7358,"date":"2024-11-14T10:34:50","date_gmt":"2024-11-14T02:34:50","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7358\/"},"modified":"2024-11-14T10:34:50","modified_gmt":"2024-11-14T02:34:50","slug":"mybatis-%e4%bc%a0%e5%8f%82%e6%97%b6%e5%a6%82%e4%bd%95%e5%a4%84%e7%90%86%e7%89%b9%e6%ae%8a%e7%ac%a6%e5%8f%b7%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7358\/","title":{"rendered":"MyBatis \u4f20\u53c2\u65f6\u5982\u4f55\u5904\u7406\u7279\u6b8a\u7b26\u53f7\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173072737917343.jpg\" class=\"aligncenter\" title=\"MyBatis \u4f20\u53c2\u65f6\u5982\u4f55\u5904\u7406\u7279\u6b8a\u7b26\u53f7\uff1f\u63d2\u56fe\" alt=\"MyBatis \u4f20\u53c2\u65f6\u5982\u4f55\u5904\u7406\u7279\u6b8a\u7b26\u53f7\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u7279\u6b8a\u7b26\u53f7\u5728 mybatis \u4f20\u53c2\u65f6\u7684\u5904\u7406<\/strong><\/p>\n<p>\u5728 mybatis \u4e2d\uff0c\u5982\u679c\u4f20\u53c2\u4e2d\u5305\u542b\u7279\u6b8a\u7b26\u53f7\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4 sql \u8bed\u53e5\u9519\u8bef\u3002\u4f8b\u5982\uff0c\u4f20\u5165\u503c\u4e3a\u95ee\u53f7 (?) \u6216\u611f\u53f9\u53f7 (!) \u65f6\uff0c\u4f1a\u63d0\u793a sql \u8bed\u6cd5\u9519\u8bef\u3002<\/p>\n<p><strong>\u539f\u56e0\u5206\u6790<\/strong><\/p>\n<p>\u636e\u5206\u6790\uff0c\u95ee\u9898\u5728\u4e8e\u7279\u6b8a\u5b57\u7b26\u672c\u8eab\u5c31\u662f sql \u8bed\u53e5\u4e2d\u7684\u5173\u952e\u5b57\uff0c\u5bfc\u81f4 sql \u8bed\u6cd5\u89e3\u6790\u51fa\u9519\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u4e3a\u4e86\u907f\u514d\u8be5\u95ee\u9898\uff0c\u9700\u8981\u5728\u4f7f\u7528\u7279\u6b8a\u5b57\u7b26\u4f5c\u4e3a\u4f20\u53c2\u65f6\u5bf9\u5176\u8fdb\u884c\u8f6c\u4e49\u5904\u7406\u3002\u5206\u9694\u7b26\u4e00\u79cd\u5e38\u89c1\u7684\u8f6c\u4e49\u65b9\u6cd5\u662f\u5728\u7279\u6b8a\u5b57\u7b26\u524d\u9762\u52a0\u4e0a\u53cd\u659c\u6760 ()\u3002<\/p>\n<p><strong>\u793a\u4f8b\u4ee3\u7801<\/strong><\/p>\n<pre>&lt;update id=\"update\"&gt;\n    update d_table set\n    separator = #{separator, jdbctype=varchar}\n    where id = #{id, jdbctype=bigint}\n&lt;\/update&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5f53 separator \u4f20\u503c\u4e3a\u7279\u6b8a\u7b26\u53f7\u65f6\uff0c\u9700\u8981\u5728\u4ee3\u7801\u4e2d\u5c06\u5176\u8f6c\u4e49\uff1a<\/p>\n<pre>Map&lt;String, Object&gt; params = new HashMap&lt;&gt;();\nparams.put(\"separator\", \"\\?\"); \/\/ \u8f6c\u4e49\u95ee\u53f7\nparams.put(\"id\", 1L);\n\nsqlSession.update(\"com.example.mapper.update\", params);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u901a\u8fc7\u8f6c\u4e49\u7279\u6b8a\u5b57\u7b26\uff0c\u53ef\u4ee5\u786e\u4fdd\u5728 mybatis \u4f20\u53c2\u65f6\u4e0d\u4f1a\u51fa\u73b0 sql \u8bed\u6cd5\u9519\u8bef\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMyBatis \u4f20\u53c2\u65f6\u5982\u4f55\u5904\u7406\u7279\u6b8a\u7b26\u53f7\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7279\u6b8a\u7b26\u53f7\u5728 mybatis \u4f20\u53c2\u65f6\u7684\u5904\u7406 \u5728 mybatis \u4e2d\uff0c\u5982\u679c\u4f20\u53c2\u4e2d\u5305\u542b\u7279\u6b8a\u7b26\u53f7\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4 sql \u8bed\u53e5\u9519\u8bef\u3002\u4f8b\u5982\uff0c\u4f20\u5165\u503c\u4e3a\u95ee\u53f7 (?) \u6216\u611f\u53f9\u53f7 (!) \u65f6\uff0c\u4f1a\u63d0\u793a sql \u8bed\u6cd5\u9519\u8bef\u3002 \u539f\u56e0\u5206\u6790 \u636e\u5206\u6790\uff0c\u95ee\u9898\u5728\u4e8e\u7279\u6b8a\u5b57\u7b26\u672c\u8eab\u5c31\u662f sql \u8bed\u53e5\u4e2d\u7684\u5173\u952e\u5b57\uff0c\u5bfc\u81f4 sql \u8bed\u6cd5\u89e3\u6790\u51fa\u9519\u3002 \u89e3\u51b3\u65b9\u6848 \u4e3a\u4e86\u907f\u514d\u8be5\u95ee\u9898\uff0c\u9700\u8981\u5728\u4f7f\u7528\u7279\u6b8a\u5b57\u7b26\u4f5c\u4e3a\u4f20\u53c2\u65f6\u5bf9\u5176\u8fdb\u884c\u8f6c\u4e49\u5904\u7406\u3002\u5206\u9694\u7b26\u4e00\u79cd\u5e38\u89c1\u7684\u8f6c\u4e49\u65b9\u6cd5\u662f\u5728\u7279\u6b8a\u5b57\u7b26\u524d\u9762\u52a0\u4e0a\u53cd\u659c\u6760 ()\u3002 \u793a\u4f8b\u4ee3\u7801 &lt;update id=&#8221;update&#8221;&gt; update d_table set separator = #{separator, jdbctype=varchar} where id = #{id, jdbctype=bigint} &lt;\/update&gt; \u767b\u5f55\u540e\u590d\u5236 \u5f53 separator \u4f20\u503c\u4e3a\u7279\u6b8a\u7b26\u53f7\u65f6\uff0c\u9700\u8981\u5728\u4ee3\u7801\u4e2d\u5c06\u5176\u8f6c\u4e49\uff1a Map&lt;String, Object&gt; params = new HashMap&lt;&gt;(); params.put(&#8220;separator&#8221;, &#8220;\\?&#8221;); \/\/ \u8f6c\u4e49\u95ee\u53f7 params.put(&#8220;id&#8221;, 1L); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-7358","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=7358"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7358\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}