{"id":8545,"date":"2022-11-15T10:07:38","date_gmt":"2022-11-15T02:07:38","guid":{"rendered":"http:\/\/123.57.164.21\/?p=8545"},"modified":"2022-11-15T10:07:38","modified_gmt":"2022-11-15T02:07:38","slug":"org-apache-ibatis-annotations-param%e6%b3%a8%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=8545","title":{"rendered":"org.apache.ibatis.annotations.Param\u6ce8\u89e3"},"content":{"rendered":"\n<p>\u5728mybatis\u7684Map\u7c7b\u4e2d\uff0c\u65b9\u6cd5\u53c2\u6570\u4e3a\u591a\u4e2a\u65f6\uff0c\u524d\u9762\u4e00\u822c\u9700\u8981\u52a0\u4e0a@Param\u6ce8\u89e3\uff0c\u4f8b\u5982<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">User getUser(@Param(\u201cuserId\u201d)String userId,@Param(\u201cpassword\u201d)String password);<\/pre>\n\n\n\n<p>@Param\u6ce8\u89e3\u5206\u4e3aspring\u7684\u548cmybatis\u7684\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">org.springframework.data.repository.query.Param\u4e0eorg.apache.ibatis.annotations.Param<\/pre>\n\n\n\n<p>\u4e24\u8005\u7684\u533a\u522b\u5728\u4e8e:<\/p>\n\n\n\n<p>\u5728\u4f7f\u7528org.springframework.data.repository.query.Param\u65f6,\u53c2\u6570\u8981\u6309\u7167\u5148\u540e\u987a\u5e8f\u4f20\u5165<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">select * from user where user_id= #{0,jdbcType=VARCHAR} and password=#{1,jdbcType=VARCHAR}<\/pre>\n\n\n\n<p>\u800c\u5728\u4f7f\u7528org.apache.ibatis.annotations.Param\u65f6\uff0c\u53ea\u9700\u8981\u4f7f\u7528\u53c2\u6570\u540d\u5373\u53ef<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">select * from user where user_id= #{userId,jdbcType=VARCHAR} and password=#{password,jdbcType=VARCHAR}<\/pre>\n\n\n\n<p>\u6240\u4ee5\u5728\u4f7f\u7528\u4e0a\uff0c\u6211\u4eec\u4e00\u822c\u90fd\u4f7f\u7528mybatis\u7684@Param\u6ce8\u89e3\uff0c\u5982\u679c\u6ca1\u6709\u4f7f\u7528@Param\u6ce8\u89e3\uff0c\u5219\u53c2\u6570\u5c06\u4f1a\u4ee5\u5b83\u4eec\u7684\u987a\u5e8f\u4f4d\u7f6e\u6765\u548cSQL\u8bed\u53e5\u4e2d\u7684\u8868\u8fbe\u5f0f\u8fdb\u884c\u6620\u5c04\u3002<\/p>\n\n\n\n<p>\u6b64\u6ce8\u89e3\u7528\u5728mapper\u4e2d\u7684\u65b9\u6cd5\u53c2\u6570\u4e2d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">public void saveProduct(@Param(\"ProductList\")List&lt;ProductList> productList);<\/pre>\n\n\n\n<p>\u901a\u5e38ibatis\u5728\u6ca1\u6709\u6307\u5b9a\u53d8\u91cf\u540d\u65f6\uff0c\u4f1a\u4f7f\u7528\u81ea\u5df1\u9ed8\u8ba4\u7684\uff0c\u6b64\u65f6\u5982\u679c\u4f60\u5199\u7684\u662f\u5176\u4ed6\u503c\uff0c\u5219\u4f1a\u62a5\u9519\uff08\u8fd9\u91cc\u7684collection\uff0c\u5982\u679c\u6ca1\u6709\u901a\u8fc7param\u6307\u5b9a\uff0c\u5219\u5e94\u8be5\u662flist\uff0carray\uff0cmap\u7b49\uff09\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;foreach collection=\"productList\" item=\"anyName\" separator=\"union all\">\n    select #{anyName.productId}.....from dual\n&lt;\/forecah><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728mybatis\u7684Map\u7c7b\u4e2d\uff0c\u65b9\u6cd5\u53c2\u6570\u4e3a\u591a\u4e2a\u65f6\uff0c\u524d\u9762\u4e00\u822c\u9700\u8981\u52a0\u4e0a@Param\u6ce8\u89e3\uff0c\u4f8b\u5982 User getUse [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,27],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/8545"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8545"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/8545\/revisions"}],"predecessor-version":[{"id":8546,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/8545\/revisions\/8546"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}