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

    1. <legend id='gdqlL'><style id='gdqlL'><dir id='gdqlL'><q id='gdqlL'></q></dir></style></legend>

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

        <bdo id='gdqlL'></bdo><ul id='gdqlL'></ul>

      1. <tfoot id='gdqlL'></tfoot>

        处理 QueryDSL 中的可选参数

        Handle optional parameters in QueryDSL(处理 QueryDSL 中的可选参数)
      2. <i id='4Rpf1'><tr id='4Rpf1'><dt id='4Rpf1'><q id='4Rpf1'><span id='4Rpf1'><b id='4Rpf1'><form id='4Rpf1'><ins id='4Rpf1'></ins><ul id='4Rpf1'></ul><sub id='4Rpf1'></sub></form><legend id='4Rpf1'></legend><bdo id='4Rpf1'><pre id='4Rpf1'><center id='4Rpf1'></center></pre></bdo></b><th id='4Rpf1'></th></span></q></dt></tr></i><div id='4Rpf1'><tfoot id='4Rpf1'></tfoot><dl id='4Rpf1'><fieldset id='4Rpf1'></fieldset></dl></div>

        1. <legend id='4Rpf1'><style id='4Rpf1'><dir id='4Rpf1'><q id='4Rpf1'></q></dir></style></legend>

            <tbody id='4Rpf1'></tbody>

          <small id='4Rpf1'></small><noframes id='4Rpf1'>

            <bdo id='4Rpf1'></bdo><ul id='4Rpf1'></ul>
          • <tfoot id='4Rpf1'></tfoot>
                  本文介绍了处理 QueryDSL 中的可选参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用带有 SpringData 的 QueryDSL.我有表说,Employee,我创建了实体类说,EmployeeEntity我写了以下 service 方法

                  I am using QueryDSL with SpringData. I have Table say, Employee and I have created entity class say, EmployeeEntity I have written following service method

                  public EmployeeEntity getEmployees(String firstName, String lastName)
                  {
                      QEmployeeEntity employee = QEmployeeEntity.employeeEntity;
                      BooleanExpression query = null;
                      if(firstName != null)
                      {
                          query = employee.firstName.eq(firstName);
                      }
                      if(lastName != null)
                      {
                          query = query.and(employee.lastName.eq(lastName)); // NPException if firstName is null as query will be NULL
                      }
                      return empployeeDAO.findAll(query);
                  }
                  

                  如上所述,我注释了 NPException.如何使用 Spring Data 将 QueryDSL 用于 QueryDSL 中的可选参数?

                  As in above I commented the NPException. How to use QueryDSL for optional Parameters in QueryDSL using Spring Data?

                  谢谢你:)

                  推荐答案

                  BooleanBuilder 可以用作布尔表达式的动态构建器:

                  BooleanBuilder can be used as a dynamic builder for boolean expressions:

                  public EmployeeEntity getEmployees(String firstName, String lastName) {
                      QEmployeeEntity employee = QEmployeeEntity.employeeEntity;
                      BooleanBuilder where = new BooleanBuilder();
                      if (firstName != null) {
                          where.and(employee.firstName.eq(firstName));
                      }
                      if (lastName != null) {
                          where.and(employee.lastName.eq(lastName));
                      }
                      return empployeeDAO.findAll(where);
                  }
                  

                  这篇关于处理 QueryDSL 中的可选参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 中的默认语言环境设置以使其保持一致?)
                          <tbody id='13sUm'></tbody>

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

                      • <tfoot id='13sUm'></tfoot>

                        <small id='13sUm'></small><noframes id='13sUm'>

                          <legend id='13sUm'><style id='13sUm'><dir id='13sUm'><q id='13sUm'></q></dir></style></legend>
                            <bdo id='13sUm'></bdo><ul id='13sUm'></ul>