{"id":4935,"date":"2020-03-27T16:49:17","date_gmt":"2020-03-27T08:49:17","guid":{"rendered":"https:\/\/www.xttblog.com\/?p=4935"},"modified":"2020-03-27T16:49:17","modified_gmt":"2020-03-27T08:49:17","slug":"attempted-to-return-null-from-a-method-with-a-primitive-return-type-int","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=4935","title":{"rendered":"attempted to return null from a method with a primitive return type (int)."},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4eca\u5929\uff0c\u516c\u53f8\u4e00\u4f4d\u540c\u4e8b\u9047\u5230\u4e86\u4e00\u4e2a MyBatis \u95ee\u9898\u201cattempted to return null from a method with a primitive return type (int).\u201d\u8bf7\u6559\u6211\u3002\u6211\u6765\u8bf4\u4e00\u8bf4\u8fd9\u7c7b\u95ee\u9898\u7684\u89e3\u51b3\u601d\u8def\uff01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\uff0c\u6211\u4eec\u6839\u636e\u9519\u8bef\u63d0\u793a\uff0c\u7ffb\u8bd1\u4e00\u4e0b\uff0c\u5927\u81f4\u662f\u8bf4\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u7684\u8fd4\u56de\u7c7b\u578b\u662f int\uff0c\u800c\u5b9e\u9645\u4e0a\u5b83\u5c06\u5c1d\u8bd5\u8fd4\u56de\u4e00\u4e2a null \u503c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6839\u636e\u8fd9\u4e2a\u9519\u8bef\u63d0\u793a\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u770b\u51fa\u662f\u65b9\u6cd5\u7684\u8fd4\u56de\u7c7b\u578b\u4e0d\u5bf9\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5177\u4f53\u518d\u770b\u5bf9\u5e94\u7684\u65b9\u6cd5\uff0c\u786e\u5b9a\u4f60\u7684 SQL \u662f\u4e0d\u662f\u4e66\u5199\u5931\u8bef\u3002\u6bd4\u5982\uff0c\u6211\u8fd9\u4e2a\u65b0\u540c\u4e8b\uff0c\u72af\u7684\u9519\u8bef\u5c31\u5f88\u4f4e\u7ea7\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>@Select(\"delete from xttblog where xttblog_id = #{id}\")<\/code><code>int deleteXttblogById(@Param(\"id\") Long id);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">delete \u8bed\u53e5\uff0c\u5199\u4e86 select \u7684\u6ce8\u89e3\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd8\u6709\u4e00\u79cd\u60c5\u51b5\uff0c\u67e5\u8be2\u65f6\uff0c\u8fd4\u56de\u7684\u8bb0\u5f55\u4e3a\u7a7a\u3002\u6bd4\u5982\uff0c\u4e0b\u9762\u7684\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>&lt;select id=\"getAgeById\" parameterType=\"java.lang.String\" resultType=\"int\"&gt;<\/code><code>    SELECT age FROM xttblog where id = #{id}<\/code><code>&lt;\/select&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u79cd\u60c5\u51b5\uff0c\u5047\u8bbe age \u8fd9\u4e2a\u5b57\u6bb5\u4e3a\u7a7a\uff0c\u90a3\u4e48 MyBatis \u518d\u628a null \u8f6c\u6210 int\uff0c\u5c31\u4f1a\u51fa\u9519\uff0c\u56e0\u6b64\u4f1a\u629b\u51fa\u8fd9\u7c7b\u4e00\u6b21\uff01<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u4ee5\uff0c\u63a8\u8350\u7684\u89e3\u51b3\u601d\u8def\u5c31\u662f\uff0c\u6839\u636e\u9519\u8bef\u63d0\u793a\uff0c\u627e\u5230\u5bf9\u5e94\u7684\u65b9\u6cd5\uff0c\u9a8c\u8bc1\u5bf9\u5e94\u7684 SQL \uff0c\u6ce8\u89e3\uff0cxml \u914d\u7f6e\u7684\u5199\u6cd5\uff01<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=4935\">attempted to return null from a method with a primitive return type (int).<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\uff0c\u516c\u53f8\u4e00\u4f4d\u540c\u4e8b\u9047\u5230\u4e86\u4e00\u4e2a MyBatis \u95ee\u9898\u201cattempted to return null from [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[266,1037,1653,414,946],"class_list":["post-4935","post","type-post","status-publish","format-standard","hentry","category-yyzt","tag-java","tag-mybatis","tag-mybatisplus","tag-spring","tag-946"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4935","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4935"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4935\/revisions"}],"predecessor-version":[{"id":4936,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/4935\/revisions\/4936"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4935"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4935"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4935"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}