<tfoot id='0wbEy'></tfoot>
        <bdo id='0wbEy'></bdo><ul id='0wbEy'></ul>

      <legend id='0wbEy'><style id='0wbEy'><dir id='0wbEy'><q id='0wbEy'></q></dir></style></legend>

        <small id='0wbEy'></small><noframes id='0wbEy'>

      1. <i id='0wbEy'><tr id='0wbEy'><dt id='0wbEy'><q id='0wbEy'><span id='0wbEy'><b id='0wbEy'><form id='0wbEy'><ins id='0wbEy'></ins><ul id='0wbEy'></ul><sub id='0wbEy'></sub></form><legend id='0wbEy'></legend><bdo id='0wbEy'><pre id='0wbEy'><center id='0wbEy'></center></pre></bdo></b><th id='0wbEy'></th></span></q></dt></tr></i><div id='0wbEy'><tfoot id='0wbEy'></tfoot><dl id='0wbEy'><fieldset id='0wbEy'></fieldset></dl></div>

        Spring Data JPA findBy/findAllBy 的区别

        时间:2024-08-24

            • <i id='SLJyr'><tr id='SLJyr'><dt id='SLJyr'><q id='SLJyr'><span id='SLJyr'><b id='SLJyr'><form id='SLJyr'><ins id='SLJyr'></ins><ul id='SLJyr'></ul><sub id='SLJyr'></sub></form><legend id='SLJyr'></legend><bdo id='SLJyr'><pre id='SLJyr'><center id='SLJyr'></center></pre></bdo></b><th id='SLJyr'></th></span></q></dt></tr></i><div id='SLJyr'><tfoot id='SLJyr'></tfoot><dl id='SLJyr'><fieldset id='SLJyr'></fieldset></dl></div>
            • <small id='SLJyr'></small><noframes id='SLJyr'>

            • <tfoot id='SLJyr'></tfoot>

                  <tbody id='SLJyr'></tbody>
                  <bdo id='SLJyr'></bdo><ul id='SLJyr'></ul>

                  <legend id='SLJyr'><style id='SLJyr'><dir id='SLJyr'><q id='SLJyr'></q></dir></style></legend>
                • 本文介绍了Spring Data JPA findBy/findAllBy 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在使用Spring Data JPA关键字时有什么区别:

                  Is there any difference when using Spring Data JPA keywords between:

                  List<SomeEntity> findBySomeCondition();
                  

                  List<SomeEntity> findAllBySomeCondition();
                  

                  推荐答案

                  不,它们之间没有区别,它们将执行完全相同的查询,All部分被Spring Data忽略时从方法名称派生查询.唯一重要的一点是 By 关键字,它后面的任何内容都被视为字段名称(除了 OrderBy 等其他关键字可能会导致一些奇怪的方法findAllByOrderByIdAsc 之类的名称).

                  No, there is no difference between them, they will execute exactly the same query, the All part is ignored by Spring Data when deriving the query from the method name. The only important bit is the By keyword, anything following it is treated as a field name (with the exception of other keywords like OrderBy which incidentially can lead to some strange looking method names like findAllByOrderByIdAsc).

                  这意味着这样的事情是完全有效的:

                  This means something like this is perfectly valid:

                  List<SomeEntity> findAnythingYouWantToPutHereBySomeCondition();
                  

                  并且将执行完全相同的 SQL 查询:

                  And will execute exactly the same SQL query as:

                  List<SomeEntity> findBySomeCondition();
                  

                  List<SomeEntity> findAllBySomeCondition();
                  

                  文档 讨论了这个特性:

                  find(或其他引入关键字)和 By 之间的任何文本都被认为是描述性的,除非使用限制结果的关键字之一,例如 Distinct 在要创建的查询上设置不同的标志或 Top/First 来限制查询结果.

                  Any text between find (or other introducing keywords) and By is considered to be descriptive unless using one of the result-limiting keywords such as a Distinct to set a distinct flag on the query to be created or Top/First to limit query results.

                  功能的目的在 博客文章 关于即将发布的 Spring Data 2.0 版本:

                  The purpose of feature was explained in a blog post about the then-upcoming 2.0 release of Spring Data:

                  Spring Data 的方法解析使用前缀关键字,如 findexistscountdelete 以及终止 关键字.您在 findBy 之间添加的所有内容都使您的方法名称更具表现力,并且不会影响查询派生.

                  Spring Data’s method parsing uses prefix keywords like find, exists, count, and delete and a terminating By keyword. Everything you put in between find and By makes your method name more expressive and does not affect query derivation.

                  这篇关于Spring Data JPA findBy/findAllBy 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:了解 Spring Data JPA @NoRepositoryBean 接口 下一篇:在 Spring Boot 中使用 JNDI 配置多个数据源

                  相关文章

                    <tfoot id='z3oy0'></tfoot>

                      <bdo id='z3oy0'></bdo><ul id='z3oy0'></ul>
                    1. <legend id='z3oy0'><style id='z3oy0'><dir id='z3oy0'><q id='z3oy0'></q></dir></style></legend>

                      <small id='z3oy0'></small><noframes id='z3oy0'>

                      <i id='z3oy0'><tr id='z3oy0'><dt id='z3oy0'><q id='z3oy0'><span id='z3oy0'><b id='z3oy0'><form id='z3oy0'><ins id='z3oy0'></ins><ul id='z3oy0'></ul><sub id='z3oy0'></sub></form><legend id='z3oy0'></legend><bdo id='z3oy0'><pre id='z3oy0'><center id='z3oy0'></center></pre></bdo></b><th id='z3oy0'></th></span></q></dt></tr></i><div id='z3oy0'><tfoot id='z3oy0'></tfoot><dl id='z3oy0'><fieldset id='z3oy0'></fieldset></dl></div>