{"id":152371,"date":"2020-09-07T11:56:49","date_gmt":"2020-09-07T03:56:49","guid":{"rendered":"http:\/\/4563.org\/?p=152371"},"modified":"2020-09-07T11:56:49","modified_gmt":"2020-09-07T03:56:49","slug":"%e4%b8%ba%e4%bb%80%e4%b9%88-mybatis-plus-%e4%b8%8d%e4%bd%bf%e7%94%a8-java-persistence-api-%e7%9a%84%e6%b3%a8%e8%a7%a3","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=152371","title":{"rendered":"\u4e3a\u4ec0\u4e48 MyBatis-Plus \u4e0d\u4f7f\u7528 Java Persistence API \u7684\u6ce8\u89e3?"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u4e3a\u4ec0\u4e48 MyBatis-Plus \u4e0d\u4f7f\u7528 Java Persistence API \u7684\u6ce8\u89e3?               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : echo1937 <\/span>  <span><i><\/i> 20<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u6700\u8fd1\u5b66\u4e60 MyBatis-Plus \uff08\u770b\u4e86 2 \u5c0f\u65f6\uff09\uff0c\u5b66\u5230\u901a\u7528 Mapper \u8fd9\u4e00\u5757\u65f6\uff0c\u6ce8\u610f\u5230\u4e86\u5b9e\u4f53\u7c7b\u7684\u51e0\u4e2a\u6ce8\u89e3\uff1a<br \/>\u8868\u540d\u6ce8\u89e3 @TableName \u3001\u4e3b\u952e\u6ce8\u89e3 @TableId \u3001\u975e\u4e3b\u952e\u5b57\u6bb5\u6ce8\u89e3 @TableField\uff0c<br \/>\u5b9e\u9645\u4e0a\uff0c\u8fd9\u51e0\u4e2a\u6ce8\u89e3\u4f5c\u7528\u548c JPA \u7684 @Table \u3001 @Id \u3001 @Column \u529f\u80fd\u57fa\u672c\u662f\u4e00\u6837\uff0c<br \/>\u7c97\u7c97\u7ffb\u4e86\u4e00\u4e0b MP\uff0c\u8bf8\u5982\u6b64\u7c7b\u7684\u6ce8\u89e3\u8fd8\u5f88\u4e0d\u5c11\u3002<\/p>\n<p>\u6309\u7406\u8bf4\uff0c@Table \u3001 @Id \u3001 @Column \u7b49\u6ce8\u89e3\u5c5e\u4e8e JPA \u89c4\u8303\uff08\u73b0\u5728\u6539\u540d\u53eb jakarta.persistence-api \uff09\uff0c<br \/>\u4e00\u822c\u90fd\u653e\u5728 javax.persistence \u7684\u5305\u8def\u5f84\u4e0b\uff0c\u5c5e\u4e8e JSR-317\uff0cJSR-338 \u89c4\u8303\u7684\u5185\u5bb9\uff0c<br \/>\u5f88\u591a\u6301\u4e45\u5c42\u6846\u67b6\u90fd\u652f\u6301\u8fd9\u4e2a\u89c4\u8303\uff0c\u9047\u5230 MyBatis-Plus \u8fd9\u6837\u6709\u81ea\u5df1\u72ec\u7acb\u6ce8\u89e3\u7684\uff0c\u6709\u70b9\u60ca\u8bb6\u3002<\/p>\n<p>\u6211\u4eec\u7684\u9879\u76ee\u4e00\u76f4\u662f Spring Data JPA \u548c MyBatis \u4e00\u8d77\u7528\uff0c\u5982\u679c\u8981\u5347\u7ea7\u6210 Spring Data JPA + MyBatis-Plus\uff0c<br \/>\u5b9e\u4f53\u7c7b\u5b57\u6bb5\u5c31\u8981\u6807\u4e0a\u4e24\u5957\u6ce8\u89e3\uff0c\u770b\u7740\u5f88\u662f\u522b\u626d\uff0c\u7ec4\u5458\u6bd4\u8f83\u6392\u65a5\u8fd9\u79cd\u7528\u6cd5\u3002<\/p>\n<p>\u8fd9\u79cd\u505a\u6cd5\u5728\u6211\u770b\u6765\uff0c\u597d\u5904\u662f\u907f\u514d\u4e86\u5f15\u5165\u5bf9 JPA \u7684\u4f9d\u8d56\uff0c\u8fd8\u6709\u5176\u4ed6\u65b9\u9762\u7684\u8003\u91cf\u5417\uff1f      <\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>13<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3036157\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rockyou12 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             mybatis \u672c\u6765\u4e5f\u4e0d\u80fd\u505a\u7c7b\u4f3c @OneToOne \u3001 @OneToMany \u8fd9\u4e9b\u7ea7\u8054\u64cd\u4f5c\uff0c\u7528\u81ea\u5df1\u7684 api \u80fd\u81ea\u5df1\u628a\u63a7\u529f\u80fd\u3002\u50cf\u4f60\u7528 Spring Data JPA\uff0c\u5f88\u591a\u529f\u80fd\u5230\u5934\u6765\u8fd8\u662f\u8981\u7528 hibernate \u7684\u5305\u7684\u6ce8\u89e3\u624d\u80fd\u5b9e\u73b0\uff0c\u6240\u4ee5\u6211\u89c9\u5f97\u5dee\u522b\u4e0d\u5927\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3036158\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : echo1937 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @rockyou12 #1 <br \/>MyBatis \u662f\u53ef\u4ee5\u901a\u8fc7 associateion \u6807\u7b7e\u6765\u8fdb\u884c\u7ea7\u8054\u64cd\u4f5c\u7684\uff0c\u6211\u4eec\u4e4b\u524d\u4e5f\u8fd9\u4e48\u505a\uff08\u4e3b\u8981\u662f\u67e5\u8be2\u573a\u666f\uff09\uff0c<br \/>Spring Data JPA \u7684\u8bdd\uff0c\u6211\u4eec\u5df2\u7ecf\u5f88\u5c11\u5f88\u5c11\u4f7f\u7528 Hibernate \u5305\u7684\u6ce8\u89e3\u4e86\uff0c\u751a\u81f3\u5f88\u591a\u65f6\u5019\u4f7f\u7528 Hibernate \u7684\u6ce8\u89e3\uff0c<br \/>\u4ed6\u4f1a\u63d0\u793a\u4f60\u4f7f\u7528 JPA \u89c4\u8303\u7684\u6ce8\u89e3\uff0c\u6bd4\u5982\u4ee5\u524d\u7ecf\u5e38\u4f7f\u7528 Hibernate \u7684 @ForeignKey \u6ce8\u89e3\uff0c\u73b0\u5728\u5df2\u7ecf @deprecated\uff0c<br \/>\u70b9\u8fdb\u53bb\u4ed6\u63d0\u793a\u4f60\uff1a@deprecated Prefer the JPA 2.1 introduced {@link javax.persistence.ForeignKey} instead.                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3036159\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 340244120w <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u80fd\u4f5c\u8005\u6709 JPA PSTD\uff0c\u6068\u5c4b\u53ca\u4e4c\uff0c\u6240\u4ee5\u4e5f\u624d\u9009\u62e9\u4e86 mybatis~                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3036160\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : haochih <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u540c\u6bd4\u8f83\u597d\u5947\uff0c\u6309\u7406\u6765\u8bf4\u6309 JSR \u89c4\u8303\u7edf\u4e00\u6389\u5bf9\u5927\u5bb6\u90fd\u6709\u597d\u5904\u3002\u4e0d\u8fc7\u4e5f\u8bf4\u4e0d\u5b9a\u4eba\u5bb6\u662f\u60f3\u81ea\u5df1\u5b9a\u6807\u51c6\u5462\u3002\/\u72d7\u5934                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3036161\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : handsomezai <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u80fd\u662f\u4e3a\u4e86\u4e2d\u6587\u7231\u597d\u8005\u4f7f\u7528\u65b9\u4fbf\u5427\uff0cidea \u67e5\u770b\u6e90\u7801\u6709\u4e2d\u6587\u6ce8\u91ca\uff0c\u5bf9\u6211\u7b49 CET6 \u672a\u8fc7\u7684\u7801\u53cb\u751a\u662f\u53cb\u597d\uff0cmp \u7684\u4e2d\u6587\u6ce8\u91ca\u633a\u597d\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3036162\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ChanKc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bed\u8a00\u969c\u788d\u7684\u5ba2\u89c2\u5b58\u5728\uff0c\u56fd\u4eba\u505a\u7684\u5f88\u591a\u4e1c\u897f\u90fd\u4f1a\u5ffd\u7565\u6389\u5df2\u6709\u7684\u4e00\u4e9b\u6280\u672f\u6807\u51c6\u548c\u89c4\u8303\uff08\u901a\u5e38\u8fd9\u4e9b\u90fd\u662f\u82f1\u6587\u5199\u7684\uff09                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3036163\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : binbinyouliiii <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6709\u5efa\u8bae\u63d0 issue                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3036164\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : pushback <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @haochih \u81ea\u5df1\u5b9a\u6807\u51c6\u7684\u7ed3\u5c40\u5c31\u548c\u76ee\u524d\u524d\u7aef\u6240\u8c13\u7684\u767e\u82b1\u9f50\u653e\u4e00\u4e2a\u4e0b\u573a\u3002<br \/>@echo1937 \u8bd5\u8bd5\u770b\u80fd\u4e0d\u80fd\u91cd\u5199\u89e3\u6790\u5668                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3036165\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rockyou12 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @echo1937 mybatis \u7ea7\u8054\u6211\u786e\u5b9e\u4e0d\u77e5\u9053\uff0c\u4f46\u4f60\u7528 jpa \u4e0d\u592a\u53ef\u80fd\u5b9a\u4e49\u4e00\u79cd\u7c7b\u4f3c @Type \u8ba9\u6240\u6709\u6846\u67b6\u90fd\u80fd\u517c\u5bb9\u3002\u800c\u81ea\u5b9a\u4e49\u7c7b\u578b\u5bf9 orm \u6846\u67b6\u8fd8\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u672c\u6765\u89c4\u8303\u518d\u597d\u4e5f\u4e0d\u53ef\u80fd\u8986\u76d6\u6240\u6709\u573a\u666f\uff0c\u4e0d\u7ba1\u54ea\u4e2a\u6846\u67b6\u603b\u8981\u6269\u5c55\u81ea\u5df1\u529f\u80fd\u3002\u867d\u7136\u6211\u4e5f\u89c9\u5f97 mybatis-plus \u662f\u53ef\u4ee5\u517c\u5bb9 jpa \u90e8\u5206\u89c4\u8303\u7684\uff0c\u4f46\u4eba\u5bb6\u4e0d\u60f3\u517c\u5bb9\u4e5f\u4e0d\u662f\u5f88\u5927\u95ee\u9898                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3036166\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : coang <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e2a\u4eba\u4e5f\u89c9\u5f97 mp \u81ea\u5b9a\u4e49\u6ce8\u89e3\u5f88\u602a.. \u6240\u4ee5\u4e2a\u4eba\u9009\u62e9 tk.mybatis \u7684\u8f85\u52a9\u6846\u67b6.. \u4f46\u662f tk \u7684\u6846\u597d\u50cf\u6ca1\u6709\u518d\u66f4\u65b0\u4e86.. \u529f\u80fd\u4e0a\u4e5f\u6ca1\u6709 mp \u9f50\u5168\u633a\u53ef\u60dc\u7684..                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3036167\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : aguesuka <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             jpa \u7684\u8bbe\u8ba1\u7406\u5ff5\u548c mybaties-plus \u7684\u4e0d\u4e00\u6837\uff0cmybatis-plus \u662f DSL to SQL \u548c ResultSet to Bean \u3002\u800c jpa \u662f DSL to Bean \u3002<\/p>\n<p>jsr \u89c4\u8303\u5e76\u4e0d\u662f\u91d1\u89c4\u7389\u5f8b\uff0c\u6bd4\u5982\u4f9d\u8d56\u6ce8\u5165\u6807\u51c6 jsr-330\uff0cspring \u867d\u7136\u5b9e\u73b0\u4e86\u8fd9\u4e2a\u6807\u51c6\uff0c\u4e0d\u8fc7\u6b63\u5e38\u7684\u9879\u76ee\u5e94\u8be5\u6ca1\u4eba\u4f7f\u7528\u5427\u3002\u800c orm \u8fdc\u6bd4 ioc \u590d\u6742\uff0c\u6211\u603b\u6709\u79cd\u841d\u535c\u5751\u7684\u611f\u89c9\u3002<br \/>mybtis-plus \u7684\u4ee3\u7801\u6b20\u89c4\u8303\u4e5f\u662f\u5f88\u5927\u4e00\u90e8\u5206\u539f\u56e0\u3002<br \/>\u8ba9 mybatis-plus \u4f7f\u7528 jpa \u7684 bean \u4e5f\u4e0d\u662f\u4e0d\u53ef\u4ee5\uff0c\u5199\u4e00\u4e2a addJpaEntityToMybatisPlus \u5e94\u8be5\u4e0d\u592a\u96be                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3036168\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yinzhili <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e3b\u53ef\u4ee5\u9009\u7528 tk mybatis mapper \u3002\u5b83\u4f7f\u7528\u7684\u57fa\u672c\u4e0a\u90fd\u662f Java Persistence API \u7684\u6ce8\u89e3\u3002<br \/>mybtis-plus \u8fd9\u4e2a\u9879\u76ee\u4e2a\u4eba\u89c9\u5f97\u4f18\u70b9\u548c\u7f3a\u70b9\u90fd\u5f88\u660e\u663e\u3002\u770b\u5f97\u51fa\u6765\u5b83\u7684\u5f00\u53d1\u56e2\u961f\u60f3\u505a\u7684\u4e8b\u60c5\u592a\u591a\uff0c\u8fd9\u5bf9\u4e8e\u4e00\u4e2a\u5de5\u5177\u5305\u6765\u8bf4\u4e0d\u4e00\u5b9a\u662f\u597d\u4e8b\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3036169\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Navee <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u6837\u66f4\u6709\u63a7\u5236\u6743\u5440~<br \/>\u4e00\u65b9\u9762\u63a7\u5236\u7528\u6237\uff0c\u8fc1\u79fb\u6210\u672c\u9ad8<br \/>\u4e8c\u65b9\u9762\u63a7\u5236\u81ea\u5df1\u7684\u9700\u6c42\uff0c\u81ea\u5b9a\u4e49\u6ce8\u89e3\u66f4\u7075\u6d3b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3a\u4ec0\u4e48 MyBatis-Plus &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/152371"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=152371"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/152371\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=152371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=152371"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=152371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}