{"id":165148,"date":"2020-10-01T05:55:26","date_gmt":"2020-09-30T21:55:26","guid":{"rendered":"http:\/\/4563.org\/?p=165148"},"modified":"2020-10-01T05:55:26","modified_gmt":"2020-09-30T21:55:26","slug":"%e5%85%b3%e4%ba%8e-spring-boot-querydsl-%e5%9c%a8%e7%bc%96%e8%af%91%e6%97%b6%e5%88%b0%e4%b8%8d%e5%88%b0%e7%88%b6%e7%b1%bb","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=165148","title":{"rendered":"\u5173\u4e8e Spring boot QueryDsl \u5728\u7f16\u8bd1\u65f6\u5230\u4e0d\u5230\u7236\u7c7b"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5173\u4e8e Spring boot QueryDsl \u5728\u7f16\u8bd1\u65f6\u5230\u4e0d\u5230\u7236\u7c7b               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : glacial <\/span>  <span><i><\/i> 1<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6211\u5728 springboot \u7684\u9879\u76ee\u4e2d\u4f7f\u7528\u4e86 QueryDsl\uff0c \u5982\u679c\u4f7f\u7528\u4e86\u7236\u7c7b\u5e76\u4e14\u4e0d\u5728\u4e00\u4e2a\u5305\u4e0b\u5728\u7f16\u8bd1\u65f6\u4f1a\u62a5\u9519\u627e\u4e0d\u5230\u7236\u7c7b\u7684&#8221;Q \u7c7b&#8221; \u4f8b\u5982 \uff1aQRootEntity<\/p>\n<p>RootEntity \u7c7b\u8def\u5f84\u662f\u5728 com.zp.mars.entity \u4e2d <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/10\/20201010_5f8185529f404.png\" alt=\"\u5173\u4e8e Spring boot QueryDsl \u5728\u7f16\u8bd1\u65f6\u5230\u4e0d\u5230\u7236\u7c7b\" \/><\/p>\n<p>User \u7c7b\u8def\u5f84\u662f\u5728 com.zp.mars.user.domain \u4e2d <img decoding=\"async\" src=\"http:\/\/4563.org\/wp-content\/uploads\/2020\/10\/20201010_5f8185572360f.png\" alt=\"\u5173\u4e8e Spring boot QueryDsl \u5728\u7f16\u8bd1\u65f6\u5230\u4e0d\u5230\u7236\u7c7b\" \/><\/p>\n<p>\u8fd9\u4e2a\u65f6\u5019\u53bb\u7f16\u8bd1 User \u7c7b\u4f1a\u62a5\u4e0d\u627e\u5230 QRootEntity \u7c7b, \u4e5f\u5c31\u662f\u8bf4 QueryDsl \u63d2\u4ef6\u662f\u9ed8\u8ba4\u4e0d\u4f1a\u627e\u5230\u7236\u7c7b\u5e76\u751f\u6210\u7236\u7c7b\u7684 Q \u7c7b\u7684 \u8fd9\u4e2a\u65f6\u5019\u6709\u4e24\u79cd\u89e3\u51b3\u529e\u6cd5<\/p>\n<p>1.\u9879\u76ee\u4e2d\u52a0\u4e0a\u4e00\u4e2a package-info \u7c7b<\/p>\n<pre><code>@QueryEntities(value = {RootEntity.class}) package com.zp.mars.entity; import com.querydsl.core.annotations.QueryEntities; import com.zp.mars.entity.RootEntity; <\/code><\/pre>\n<p>2.\u56e0\u4e3a\u6211\u7528\u7684\u662f\u5fae\u670d\u52a1\u8fd9\u6837\u5728\u6bcf\u4e2a\u9879\u76ee\u7684\u4e2d\u52a0\u4e0a package-info \u7c7b\u6211\u89c9\u5f97\u6709\u70b9\u9ebb\u70e6.\u6240\u4ee5\u6211\u5c31\u628a\u751f\u6210\u597d\u7684 QRootEntity \u7c7b\u62f7\u5230\u4e86 com.zp.mars.entity \u4e0b \u8fd9\u6837\u4e5f\u53ef\u4ee5\u7f16\u8bd1\u901a\u8fc7. \u56e0\u4e3a\u6211\u7684 RootEntity \u57fa\u672c\u4e0a\u4e0d\u4f1a\u6709\u53d8\u5316\u4e86\u6240\u4ee5\u6211\u89c9\u5f97\u53ef\u4ee5\u8fd9\u4e48\u505a<\/p>\n<p>\u4e0d\u77e5\u9053\u5927\u5bb6\u8fd8\u6709\u6ca1\u6709\u66f4\u597d\u7684\u529e\u6cd5<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3628597\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Jooooooooo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u653e\u5230\u4e00\u4e2a common \u5305\u91cc, \u5927\u5bb6\u90fd\u5f15\u8fd9\u4e2a\u5305.                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3628598\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : glacial <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Jooooooooo \u662f\u7684 \u6211\u7684 com.zp.mars.entity.RootEntity \u5c31\u662f\u4e2a\u4e00\u4e2a common \u5305\u91cc\u9762                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3628599\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : crclz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6b6a\u4e2a\uff0c\u6211\u4e2a\u4eba\u8ba4\u4e3a QueryDSL \u5f88\u65e0\u7528\u3002<\/p>\n<p>\u4e8b\u52a1\u7c7b\u8bf7\u6c42\u76f4\u63a5\u4f7f\u7528 JpaRepository \u3002<\/p>\n<p>\u67e5\u8be2\u7c7b\u8bf7\u6c42\u76f4\u63a5\u5199 sql\uff0c\u4e00\u65b9\u9762\u662f\u56e0\u4e3a sql \u672c\u8eab\u662f\u4e00\u4e2a\u5f88\u6210\u719f\u3001\u6613\u7f16\u5199\u3001\u6613\u7406\u89e3\u7684\u8bed\u8a00\uff0c\u53e6\u4e00\u65b9\u9762\u662f\u56e0\u4e3a IDEA \u6709 sql \u667a\u80fd\u63d0\u793a\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3628600\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wangyanrui <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @glacial common \u5305\u4e5f\u5bfc\u5165 querydsl \u7684 jar \u548c maven \u63d2\u4ef6\u5373\u53ef                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5173\u4e8e Spring boot Qu&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\/165148"}],"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=165148"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/165148\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=165148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=165148"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=165148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}