• <legend id='ASvl6'><style id='ASvl6'><dir id='ASvl6'><q id='ASvl6'></q></dir></style></legend>

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

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

        Spring Data JPA:通过示例查询?

        Spring Data JPA: Query by Example?(Spring Data JPA:通过示例查询?)

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

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

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

                  问题描述

                  使用 Spring Data JPA 我可以做一个 通过示例查询其中使用特定实体实例作为搜索条件?

                  Using Spring Data JPA can I do a query by example where a particular entity instance is used as the search criteria?

                  例如(没有双关语),如果我有一个 Person 实体,看起来像:

                  For example (no pun intended), if I have a Person entity that looks like:

                  @Entity
                  public class Person {
                    private String firstName;
                    private String lastName;
                    private boolean employed;
                    private LocalDate dob;
                    ...
                  }
                  

                  我可以找到所有姓氏为 Smith 出生于 1977 年 1 月 1 日的雇员,例如:

                  I could find all employed persons with a last name of Smith born on January 1, 1977 with an example:

                  Person example = new Person();
                  example.setEmployed(true);
                  example.setLastName("Smith");
                  example.setDob(LocalDate.of(1977, Month.JANUARY, 1));
                  List<Person> foundPersons = personRepository.findByExample(example);
                  

                  推荐答案

                  Spring 数据依赖于 JPA 和 EntityManager,而不是 Hibernate 和 Session,因此您没有开箱即用的 findByExample.您可以使用spring数据自动查询创建并在您的存储库中编写一个具有以下签名的方法:

                  Spring data relies on top of JPA and EntityManager, not Hibernate and Session, and as such you do not have findByExample out of the box. You can use the spring data automatic query creation and write a method in your repository with the following signature:

                  List<Person> findByEmployedAndLastNameAndDob(boolean employed, String lastName, LocalDate dob);
                  

                  这篇关于Spring Data JPA:通过示例查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                  <small id='6TI3g'></small><noframes id='6TI3g'>

                    <bdo id='6TI3g'></bdo><ul id='6TI3g'></ul>
                    1. <tfoot id='6TI3g'></tfoot>

                          • <legend id='6TI3g'><style id='6TI3g'><dir id='6TI3g'><q id='6TI3g'></q></dir></style></legend>
                            <i id='6TI3g'><tr id='6TI3g'><dt id='6TI3g'><q id='6TI3g'><span id='6TI3g'><b id='6TI3g'><form id='6TI3g'><ins id='6TI3g'></ins><ul id='6TI3g'></ul><sub id='6TI3g'></sub></form><legend id='6TI3g'></legend><bdo id='6TI3g'><pre id='6TI3g'><center id='6TI3g'></center></pre></bdo></b><th id='6TI3g'></th></span></q></dt></tr></i><div id='6TI3g'><tfoot id='6TI3g'></tfoot><dl id='6TI3g'><fieldset id='6TI3g'></fieldset></dl></div>
                              <tbody id='6TI3g'></tbody>