{"id":1116,"date":"2020-07-29T15:01:34","date_gmt":"2020-07-29T07:01:34","guid":{"rendered":"http:\/\/diuut.com\/?p=1116"},"modified":"2020-07-29T15:05:03","modified_gmt":"2020-07-29T07:05:03","slug":"jpa-page-1-of-0-containing-unknown-instances%e9%94%99%e8%af%af","status":"publish","type":"post","link":"https:\/\/diuut.com\/?p=1116","title":{"rendered":"jpa Page 1 of 0 containing UNKNOWN instances\u9519\u8bef"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote\"><p>\u95ee\u9898\u6392\u67e5<\/p><\/blockquote>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n @Autowired\n    WeekRankDao weekRankDao;\n    @Test\n    public void test(){\n        Sort sort = Sort.by(Sort.Direction.DESC, &quot;winChip&quot;);\n        Pageable pageable = PageRequest.of(0, 5, sort);\n        WeekRank weekRank=new WeekRank();\n        weekRank.setWeek(174);\n        log.info(&quot;weekRank:{}&quot;, weekRank);\n        Example&lt;WeekRank&gt; example = Example.of(weekRank);\n        Page&lt;WeekRank&gt; rankPage = weekRankDao.findAll(example,pageable);\n        log.info(&quot;rankPage:{}&quot;, rankPage);\n        List&lt;WeekRank&gt; content = rankPage.getContent();\n        log.info(&quot;content:{}&quot;, content);\n    }\n<\/pre><\/div>\n\n\n<p>\u9519\u8bef\u4ee3\u7801\uff1ajpa Page 1 of 0 containing UNKNOWN instances\u9519\u8bef<\/p>\n\n\n\n<p>\u7f51\u4e0a\u641c\u7d22\u7c7b\u4f3c\u7684\u60c5\u51b5\u6709\u7684\u8bf4\u662f\u56e0\u4e3a\u4f20\u5165\u9875\u6570\u9519\u8bef\u5bfc\u81f4\uff0c\u4f46\u662f\u6211\u6362\u62100\uff0c\u8fd8\u662f1\u90fd\u4e00\u6837\u7684\u9519\u8bef\uff0c\u6240\u4ee5\u6392\u9664\u9875\u7801\u9519\u8bef\u3002\u6700\u7ec8\u5b9a\u4f4d\u5230\u4e00\u822c\u662f\u4f60\u591a\u4e2a\u6761\u4ef6\u67e5\u8be2\u65f6\uff0c\u6709\u6761\u4ef6\u6dfb\u52a0\u8fdb\u53bb\u4e86\uff0c\u4f46\u4e3a\u7a7a\u6761\u4ef6\u3002\u4f46\u6211\u4ee3\u7801example\u6a21\u677f\u4e2d\u786e\u5b9a\u53ea\u4f20\u5165\u4e86\u4e00\u4e2a\u6761\u4ef6\uff0c\u5982\u679c\u6709\u7a7a\u7684\u8bdd\u5e94\u8be5\u5c31\u4e0d\u662f\u4ee3\u7801\u7684\u95ee\u9898\uff0c\u6700\u540e\u53c8\u5b9a\u4f4d\u5230\u4e86\u5b9e\u4f53\u7c7b\u4e2d.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n@Data\n@Entity\npublic class WeekRank {\n    @Id\n    @GeneratedValue(strategy = GenerationType.IDENTITY)\n    private int id;\n    private int uid;\n    private String name;\n    private int week;\n    ``````\n}\n<\/pre><\/div>\n\n\n<p>\u53d1\u73b0\u5b9e\u4f53\u7c7b\u4e2d\u6240\u6709\u6570\u5b57\u5b57\u6bb5\u7686\u4e3aint\u7c7b\u578b\uff0c\u800cint\u7c7b\u578b\u9ed8\u8ba4\u503c\u4e3a0\uff0c\u8fd9\u662f\u5426\u5c31\u662f\u5bfc\u81f4\u4e86JPA\u8ba4\u5b9a\u7684\u7a7a\u6761\u4ef6\uff0c\u4e8e\u662f\u628a\u6240\u6709\u7684int \u6362\u6210\u5305\u88c5\u7c7bInteger\u3002\u540c\u6837\u7684\u4ee3\u7801\u8fdb\u884c\u6d4b\u8bd5\uff0c\u7ed3\u679c\u663e\u793a\u6b63\u5e38\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n@Data\n@Entity\npublic class WeekRank {\n    @Id\n    @GeneratedValue(strategy = GenerationType.IDENTITY)\n    private Integer id;\n    private Integer uid;\n    private String name;\n    private Integer week;\n    ``````\n}\n<\/pre><\/div>\n\n\n<p>\u603b\u7ed3\uff1a \u80fd\u7528Integer\u5c31\u4e0d\u7528int\uff0c\u5f53\u57fa\u672c\u6570\u636e\u7c7b\u578b\u5b9a\u4e49\u7684\u53d8\u91cf\u4f5c\u4e3a\u7c7b\u7684\u6210\u5458\u4f7f\u7528\u65f6\uff0cJava\u4f1a\u786e\u4fdd\u7ed9\u5b9a\u9ed8\u8ba4\u503c\uff0c\u4ee5\u4fdd\u8bc1\u8fd9\u4e9b\u6210\u5458\u53d8\u91cf\u5f97\u5230\u521d\u59cb\u5316\uff0c\u4ee5\u9632\u6b62\u4ea7\u751f\u7a0b\u5e8f\u9519\u8bef\u3002\u4f46\u662f\uff0c\u8fd9\u4e9b\u521d\u59cb\u503c\u5bf9\u7a0b\u5e8f\u6765\u8bf4\uff0c\u53ef\u80fd\u4e0d\u6b63\u786e\uff0c\u751a\u81f3\u662f\u4e0d\u5408\u6cd5\u7684\uff0c\u6bd4\u5982\u5728\u6b64\u5904\u7684JPA\u6a21\u677f\u67e5\u8be2\u4e2d\u5c31\u662f\u975e\u6cd5\u7684\u7a7a\u6761\u4ef6\u3002\u5982\u679c\u4e00\u5b9a\u8981\u4f7f\u7528\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff0c\u6700\u597d\u660e\u786e\u5730\u5bf9\u53d8\u91cf\u8fdb\u884c\u521d\u59cb\u5316\u3002\u5728\u5bf9\u5e94\u6570\u636e\u5e93\u4e2d\u7684\u6570\u503c\u7c7b\u578b\u65f6\uff0c\u4e2a\u4eba\u5f3a\u70c8\u5efa\u8bae\u4f7f\u7528Integer\uff01\u4e0d\u80fd\u56e0\u4e3a\u4e00\u65f6\u7684\u60f3\u6cd5\u5c31\u53bb\u5077\u61d2\uff0c\u800c\u7559\u4e0b\u5b89\u5168\u9690\u60a3\u3002 <\/p>\n\n\n\n<p>\u53c2\u8003\uff1a<\/p>\n\n\n\n<ul><li> <a href=\"https:\/\/blog.csdn.net\/qq_31424825\/article\/details\/81334814\">https:\/\/blog.csdn.net\/qq_31424825\/article\/details\/81334814<\/a> <\/li><li> <a href=\"https:\/\/blog.csdn.net\/zhangzz1127\/article\/details\/10251701\/\">https:\/\/blog.csdn.net\/zhangzz1127\/article\/details\/10251701\/<\/a> <\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898\u6392\u67e5 \u9519\u8bef\u4ee3\u7801\uff1ajpa Page 1 of 0 containing UNKNOWN instances\u9519<span class=\"more-button\"><a href=\"https:\/\/diuut.com\/?p=1116\" class=\"more-link\">view all . . .<span class=\"screen-reader-text\">jpa Page 1 of 0 containing UNKNOWN instances\u9519\u8bef<\/span><\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":1092,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/posts\/1116"}],"collection":[{"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1116"}],"version-history":[{"count":2,"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/posts\/1116\/revisions"}],"predecessor-version":[{"id":1118,"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/posts\/1116\/revisions\/1118"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=\/wp\/v2\/media\/1092"}],"wp:attachment":[{"href":"https:\/\/diuut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/diuut.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}