{"id":1037,"date":"2019-06-22T13:47:20","date_gmt":"2019-06-22T04:47:20","guid":{"rendered":"https:\/\/ito-u-oti.com\/?p=1037"},"modified":"2020-07-10T17:25:57","modified_gmt":"2020-07-10T08:25:57","slug":"post-1037","status":"publish","type":"post","link":"https:\/\/ito-u-oti.com\/?p=1037","title":{"rendered":"\u3010Spring Boot\u3011\u3010Mybatis\u3011Xml\u30d9\u30fc\u30b9\u3067\u5358\u4e00SQL\u306e\u30cd\u30b9\u30c8\u306b\u3088\u308b\u30de\u30c3\u30d4\u30f3\u30b0\u5b9f\u88c5"},"content":{"rendered":"\n<p><a href=\"https:\/\/ito-u-oti.com\/post-1029\/\">\u524d\u56de<\/a>\u306e\u7d9a\u304d\u3067\u3059\u3002<br>\u524d\u63d0\u306a\u3069\u306f\u524d\u56de\u306e\u8a18\u4e8b\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h2 id=\"outline__1\" class=\"wp-block-heading\"> Xml\u30d9\u30fc\u30b9\u3067\u5358\u4e00SQL\u306e\u30cd\u30b9\u30c8\u306b\u3088\u308b\u30de\u30c3\u30d4\u30f3\u30b0\u5b9f\u88c5  <\/h2>\n\n\n\n<p>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u30d9\u30fc\u30b9\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u5b9f\u88c5\u3092XML\u3092\u4f7f\u7528\u3057\u305f\u5b9f\u88c5\u306b\u3057\u305f\u3089\u3069\u3046\u306a\u308b\u304b\u30fb\u30fb\u30fb\uff1f\u3068\u3044\u3046\u306e\u304c\u4e3b\u984c\u3067\u3059\u3002<\/p>\n\n\n\n<h2 id=\"outline__2\" class=\"wp-block-heading\">\u30b3\u30fc\u30c9<\/h2>\n\n\n\n<h3 id=\"outline__2_1\" class=\"wp-block-heading\">DemoMapperXmlSepalete.java<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\npackage com.example.demo.repository;\n\nimport org.apache.ibatis.annotations.Mapper;\nimport org.apache.ibatis.annotations.Param;\n\nimport com.example.demo.entity.Country;\n\n@Mapper\npublic interface DemoMapperXmlSepalate {\n\n    Country selectCountry(@Param(&quot;id&quot;)Integer id);\n    \n}\n<\/pre><\/div>\n\n\n<p>\u304b\u306a\u308a\u3059\u3063\u304d\u308a\u3057\u307e\u3057\u305f\u3002<br>SQL\u3068\u30de\u30c3\u30d4\u30f3\u30b0\u3092\u5168\u3066XML\u306b\u3057\u305f\u306e\u3067\u5f53\u7136\u3068\u8a00\u3048\u3070\u5f53\u7136\u3002<\/p>\n\n\n\n<h3 id=\"outline__2_2\" class=\"wp-block-heading\">DemoMapperXmlSepalete.xml<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;\n&lt;!DOCTYPE mapper\n        PUBLIC &quot;-\/\/mybatis.org\/\/DTD Mapper 3.0\/\/EN&quot;\n        &quot;http:\/\/mybatis.org\/dtd\/mybatis-3-mapper.dtd&quot;&gt;\n&lt;mapper namespace=&quot;com.example.demo.repository.DemoMapperXmlSepalate&quot;&gt;\n    \n    &lt;resultMap id=&quot;countryMap&quot; type=&quot;com.example.demo.entity.Country&quot; &gt;\n    \n        &lt;result column=&quot;country&quot; property=&quot;country&quot; \/&gt;\n        &lt;result column=&quot;last_update&quot; property=&quot;lastUpdate&quot; \/&gt;\n        &lt;association property=&quot;id&quot; column=&quot;country_id&quot; select=&quot;selectCountryId&quot; \/&gt;\n        &lt;collection property=&quot;city&quot; column=&quot;country_id&quot; select=&quot;selectCity&quot; \/&gt;\n    \n    &lt;\/resultMap&gt;\n    &lt;select\n        id=&quot;selectCountry&quot;\n        resultMap=&quot;countryMap&quot;&gt;\n        SELECT *\n        FROM\n            country\n        WHERE\n            country_id = #{id}\n    &lt;\/select&gt;\n    \n    &lt;resultMap id=&quot;countryIdMap&quot; type=&quot;com.example.demo.entity.CountryId&quot; &gt;\n        &lt;result column=&quot;country_id&quot; property=&quot;countryId&quot; \/&gt;\n    &lt;\/resultMap&gt;\n    &lt;select\n        id=&quot;selectCountryId&quot;\n        resultMap=&quot;countryIdMap&quot;&gt;\n        SELECT *\n        FROM\n            country\n        WHERE\n            country_id = #{id}\n    &lt;\/select&gt;\n    \n    \n    &lt;resultMap id=&quot;cityMap&quot; type=&quot;com.example.demo.entity.City&quot; &gt;\n        &lt;result column=&quot;city_id&quot; property=&quot;cityId&quot; \/&gt;\n        &lt;result column=&quot;city&quot; property=&quot;city&quot; \/&gt;\n        &lt;result column=&quot;last_update&quot; property=&quot;lastUpdate&quot; \/&gt;\n        &lt;collection property=&quot;address&quot; column=&quot;city_id&quot; select=&quot;selectAdress&quot; \/&gt;\n    &lt;\/resultMap&gt;\n    &lt;select\n        id=&quot;selectCity&quot;\n        resultMap=&quot;cityMap&quot;&gt;\n        SELECT *\n        FROM\n            city\n        WHERE\n            country_id = #{id}\n    &lt;\/select&gt;\n    \n    &lt;resultMap id=&quot;addressMap&quot; type=&quot;com.example.demo.entity.Address&quot; &gt;\n    &lt;result column=&quot;address_id&quot; property=&quot;addressId&quot; \/&gt;\n        &lt;result column=&quot;address&quot; property=&quot;address&quot; \/&gt;\n        &lt;result column=&quot;address2&quot; property=&quot;address2&quot; \/&gt;\n        &lt;result column=&quot;district&quot; property=&quot;district&quot; \/&gt;\n        &lt;result column=&quot;postal_code&quot; property=&quot;postalCode&quot; \/&gt;\n        &lt;result column=&quot;phone&quot; property=&quot;phone&quot; \/&gt;\n        &lt;result column=&quot;last_update&quot; property=&quot;lastUpdate&quot; \/&gt;\n    &lt;\/resultMap&gt;\n    &lt;select\n        id=&quot;selectAdress&quot;\n        resultMap=&quot;addressMap&quot;&gt;\n        SELECT *\n        FROM\n            address\n        WHERE\n            city_id = #{id}\n    &lt;\/select&gt;\n&lt;\/mapper&gt;\n<\/pre><\/div>\n\n\n<h2 id=\"outline__3\" class=\"wp-block-heading\">\u8aac\u660e<\/h2>\n\n\n\n<p>\u6700\u521d\u306emapper.namespace\u5c5e\u6027\u3067\u3001\u30de\u30c3\u30d1\u30fc\u30a4\u30f3\u30bf\u30d5\u30a7\u30fc\u30b9\uff08DemoMapperXmlSepalete.java\uff09\u3068\u30de\u30c3\u30d4\u30f3\u30b0\u3057Mybatis\u3067\u8a8d\u8b58\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u5185\u5bb9\u306f\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u30d9\u30fc\u30b9\u306e\u30bd\u30fc\u30b9\u3068\u898b\u6bd4\u3079\u3066\u3082\u3089\u3048\u308c\u3070\u5927\u4f53\u308f\u304b\u308b\u3068\u601d\u3044\u307e\u3059\u3002<br>@One\u304cXml\u3067\u306fassosiation\u30bf\u30b0\u306b\u306a\u308a\u3001<br>@Many\u304cXml\u3067\u306fCollection\u30bf\u30b0\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 id=\"outline__4\" class=\"wp-block-heading\">\u7d50\u679c<\/h2>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" src=\"https:\/\/ito-u-oti.com\/wp-content\/uploads\/2019\/06\/spring-mybatisMapper2.png\" alt=\"\" class=\"wp-image-1038\" width=\"536\" height=\"471\"\/><\/figure>\n\n\n\n<p>\u30a2\u30ce\u30c6\u30fc\u30b7\u30e7\u30f3\u30d9\u30fc\u30b9\u3068\u540c\u3058\u304f\u30cd\u30b9\u30c8\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3078\u306e\u30de\u30c3\u30d4\u30f3\u30b0\u304c\u51fa\u6765\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h2 id=\"outline__5\" class=\"wp-block-heading\"> Xml\u30d9\u30fc\u30b9\u3067\u7d50\u5408SQL\u306b\u3088\u308b\u30de\u30c3\u30d4\u30f3\u30b0\u5b9f\u88c5  <\/h2>\n\n\n\n<p>\u9577\u304f\u306a\u3063\u3066\u3057\u307e\u3063\u305f\u306e\u3067\u7d9a\u304d\u306f\u5225\u8a18\u4e8b\u3067  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306e\u7d9a\u304d\u3067\u3059\u3002\u524d\u63d0\u306a\u3069\u306f\u524d\u56de\u306e\u8a18\u4e8b\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002 Xml\u30d9\u30fc\u30b9\u3067\u5358\u4e00SQL\u306e\u30cd\u30b9\u30c8\u306b\u3088\u308b\u30de\u30c3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":273,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[242,240,241,13,239,238],"class_list":["post-1037","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mybatis","tag-annotation","tag-many","tag-mapper","tag-mybatis","tag-one","tag-spring-boot"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/posts\/1037","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1037"}],"version-history":[{"count":5,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/posts\/1037\/revisions"}],"predecessor-version":[{"id":1217,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/posts\/1037\/revisions\/1217"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=\/wp\/v2\/media\/273"}],"wp:attachment":[{"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1037"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1037"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ito-u-oti.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1037"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}