{"id":7723,"date":"2024-11-14T12:23:02","date_gmt":"2024-11-14T04:23:02","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7723\/"},"modified":"2024-11-14T12:23:02","modified_gmt":"2024-11-14T04:23:02","slug":"mybatis-%e6%89%b9%e9%87%8f%e6%8f%92%e5%85%a5%e6%95%b0%e6%8d%ae%e6%97%b6%ef%bc%8c%e6%8b%a6%e6%88%aa%e5%99%a8%e4%b8%ba%e4%bb%80%e4%b9%88%e5%a4%b1%e6%95%88%ef%bc%8c%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7723\/","title":{"rendered":"MyBatis \u6279\u91cf\u63d2\u5165\u6570\u636e\u65f6\uff0c\u62e6\u622a\u5668\u4e3a\u4ec0\u4e48\u5931\u6548\uff0c\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173119952471709.jpg\" class=\"aligncenter\" title=\"MyBatis \u6279\u91cf\u63d2\u5165\u6570\u636e\u65f6\uff0c\u62e6\u622a\u5668\u4e3a\u4ec0\u4e48\u5931\u6548\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"MyBatis \u6279\u91cf\u63d2\u5165\u6570\u636e\u65f6\uff0c\u62e6\u622a\u5668\u4e3a\u4ec0\u4e48\u5931\u6548\uff0c\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>mybatis\u6279\u91cf\u63d2\u5165\u6570\u636e\u65f6\u62e6\u622a\u5668\u5931\u6548<\/strong><\/p>\n<p>\u95ee\u9898\u63cf\u8ff0\uff1a\u5728\u9879\u76ee\u4e2d\u4f7f\u7528mybatis\u7f16\u5199\u4e86\u62e6\u622a\u5668\uff0c\u4e3a\u63d2\u5165\u6216\u66f4\u65b0\u7684\u6570\u636e\u81ea\u52a8\u586b\u5145\u57fa\u7840\u5b57\u6bb5\u503c\u3002\u4f46\u5728\u4f7f\u7528\u6279\u91cf\u63d2\u5165\u6570\u636e\u7684\u65b9\u6cd5\u65f6\uff0c\u62e6\u622a\u5668\u5374\u5931\u6548\uff0c\u5bfc\u81f4\u57fa\u7840\u5b57\u6bb5\u65e0\u6cd5\u8d4b\u503c\u3002<\/p>\n<p>\u4ee3\u7801\u793a\u4f8b\uff1a<\/p>\n<pre>@component\n@intercepts({\n        @signature(type = executor.class,method = \"update\",args = {mappedstatement.class, object.class})\n})\npublic class mybatisautofillplugin implements interceptor {\n    \/\/ ...\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u4e2a\u95ee\u9898\u7684\u6839\u6e90\u5728\u4e8e\u6279\u91cf\u63d2\u5165\u8bed\u53e5\u4f7f\u7528\u7684\u662fforeach\u6807\u7b7e\uff0c\u8be5\u6807\u7b7e\u4f1a\u5c06\u4e00\u4e2a\u96c6\u5408\u4e2d\u7684\u5143\u7d20\u9010\u4e00\u63d2\u5165\u5230\u6570\u636e\u5e93\u4e2d\u3002\u6b64\u65f6\u62e6\u622a\u5668\u53ea\u62e6\u622a\u4e86executor.update\u65b9\u6cd5\uff0c\u65e0\u6cd5\u62e6\u622a\u6279\u91cf\u63d2\u5165\u7684\u6267\u884c\u8fc7\u7a0b\u3002\u56e0\u6b64\u9700\u8981\u989d\u5916\u62e6\u622astatementhandler.update\u65b9\u6cd5\u6765\u89e3\u51b3\u6b64\u95ee\u9898\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<pre>@Intercepts({\n        @Signature(type = Executor.class,method = \"update\",args = {MappedStatement.class, Object.class}),\n        @Signature(type = StatementHandler.class,method = \"update\",args = {Statement.class})\n})\npublic class MyBatisAutoFillPlugin implements Interceptor {\n    \/\/ ...\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6dfb\u52a0\u62e6\u622astatementhandler.update\u65b9\u6cd5\u540e\uff0c\u62e6\u622a\u5668\u5373\u53ef\u6b63\u5e38\u5de5\u4f5c\uff0c\u4e3a\u6279\u91cf\u63d2\u5165\u7684\u6570\u636e\u6b63\u786e\u586b\u5145\u57fa\u7840\u5b57\u6bb5\u503c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMyBatis \u6279\u91cf\u63d2\u5165\u6570\u636e\u65f6\uff0c\u62e6\u622a\u5668\u5931\u6548\uff0c\u5982\u4f55\u89e3\u51b3\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>mybatis\u6279\u91cf\u63d2\u5165\u6570\u636e\u65f6\u62e6\u622a\u5668\u5931\u6548 \u95ee\u9898\u63cf\u8ff0\uff1a\u5728\u9879\u76ee\u4e2d\u4f7f\u7528mybatis\u7f16\u5199\u4e86\u62e6\u622a\u5668\uff0c\u4e3a\u63d2\u5165\u6216\u66f4\u65b0\u7684\u6570\u636e\u81ea\u52a8\u586b\u5145\u57fa\u7840\u5b57\u6bb5\u503c\u3002\u4f46\u5728\u4f7f\u7528\u6279\u91cf\u63d2\u5165\u6570\u636e\u7684\u65b9\u6cd5\u65f6\uff0c\u62e6\u622a\u5668\u5374\u5931\u6548\uff0c\u5bfc\u81f4\u57fa\u7840\u5b57\u6bb5\u65e0\u6cd5\u8d4b\u503c\u3002 \u4ee3\u7801\u793a\u4f8b\uff1a @component @intercepts({ @signature(type = executor.class,method = &#8220;update&#8221;,args = {mappedstatement.class, object.class}) }) public class mybatisautofillplugin implements interceptor { \/\/ &#8230; } \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u4e2a\u95ee\u9898\u7684\u6839\u6e90\u5728\u4e8e\u6279\u91cf\u63d2\u5165\u8bed\u53e5\u4f7f\u7528\u7684\u662fforeach\u6807\u7b7e\uff0c\u8be5\u6807\u7b7e\u4f1a\u5c06\u4e00\u4e2a\u96c6\u5408\u4e2d\u7684\u5143\u7d20\u9010\u4e00\u63d2\u5165\u5230\u6570\u636e\u5e93\u4e2d\u3002\u6b64\u65f6\u62e6\u622a\u5668\u53ea\u62e6\u622a\u4e86executor.update\u65b9\u6cd5\uff0c\u65e0\u6cd5\u62e6\u622a\u6279\u91cf\u63d2\u5165\u7684\u6267\u884c\u8fc7\u7a0b\u3002\u56e0\u6b64\u9700\u8981\u989d\u5916\u62e6\u622astatementhandler.update\u65b9\u6cd5\u6765\u89e3\u51b3\u6b64\u95ee\u9898\u3002 \u89e3\u51b3\u65b9\u6cd5\uff1a @Intercepts({ @Signature(type = Executor.class,method = &#8220;update&#8221;,args = {MappedStatement.class, Object.class}), @Signature(type = StatementHandler.class,method = &#8220;update&#8221;,args = {Statement.class}) }) public class MyBatisAutoFillPlugin implements Interceptor { \/\/ &#8230; } \u767b\u5f55\u540e\u590d\u5236 \u6dfb\u52a0\u62e6\u622astatementhandler.update\u65b9\u6cd5\u540e\uff0c\u62e6\u622a\u5668\u5373\u53ef\u6b63\u5e38\u5de5\u4f5c\uff0c\u4e3a\u6279\u91cf\u63d2\u5165\u7684\u6570\u636e\u6b63\u786e\u586b\u5145\u57fa\u7840\u5b57\u6bb5\u503c\u3002 \u4ee5\u4e0a\u5c31\u662fMyBatis [&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-7723","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7723","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=7723"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7723\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7723"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7723"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7723"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}