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

    <legend id='8tLmx'><style id='8tLmx'><dir id='8tLmx'><q id='8tLmx'></q></dir></style></legend>
  • <tfoot id='8tLmx'></tfoot>

      <bdo id='8tLmx'></bdo><ul id='8tLmx'></ul>

      <small id='8tLmx'></small><noframes id='8tLmx'>

      1. QueryDsl - 集合表达式中的子查询

        QueryDsl - subquery in collection expression(QueryDsl - 集合表达式中的子查询)
          <tbody id='iNP5L'></tbody>

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

              <legend id='iNP5L'><style id='iNP5L'><dir id='iNP5L'><q id='iNP5L'></q></dir></style></legend>
                <bdo id='iNP5L'></bdo><ul id='iNP5L'></ul>
                • <small id='iNP5L'></small><noframes id='iNP5L'>

                • 本文介绍了QueryDsl - 集合表达式中的子查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 spring-data-jpa 和 querydsl (3.2.3)
                  我有一个场景,我正在根据用户文件管理器/输入创建一组谓词.所有这些都来自 BooleanExpression.

                  I'm using spring-data-jpa and querydsl (3.2.3)
                  I have a scenario where I'm creating set of predicates based on user filer/input. All of these comes to BooleanExpression.

                  我的简化模型如下所示:

                  My simplified model looks as following:

                  @Entity
                  public class Invoice {
                      @ManyToOne
                      private Supplier supplier;
                  }
                  
                  @Entity
                  public class Supplier {
                      private String number;
                  }
                  
                  @Entity
                  public class Company {
                      private String number;
                      private boolean active
                  }
                  

                  现在,我正在努力解决这个问题:

                  Now, what I'm struggling with is this query:

                  SELECT * FROM Invoice WHERE invoice.supplier.number in (SELECT number from Company where active=true)
                  

                  所以基本上我需要以 CollectionExpression 之类的格式进行子查询,该格式将获取所有公司编号并将其设置为 in() 表达式.

                  So basically I need to subquery in CollectionExpression like format that will fetch all companies numbers and sets this into in() expression.

                  我的 spring-data 存储库实现了 CustomQueryDslJpaRepository,后者又扩展了 JpaRepositoryQueryDslPredicateExecutor.
                  我希望这个问题的答案是直截了当的,但我对 querydsl 很陌生,到目前为止还没有找到解决方案.

                  My spring-data repositories implements CustomQueryDslJpaRepository which in turn extends JpaRepository and QueryDslPredicateExecutor.
                  I hope the answer to this is straightforward, but I'm quite new to querydsl and didn't find the solutions so far.

                  推荐答案

                  这里是 jaiwo99 答案的变体,更 JPAesque 形式

                  Here is a variant of jaiwo99's answer in a more JPAesque form

                  BooleanExpression exp = invoice.supplier.number.in(new JPASubQuery()
                      .from(company)
                      .where(company.active.isTrue())
                      .list(company.number));
                  

                  请随意将其合并到原始答案中.

                  Feel free to merge this into the original answer.

                  这篇关于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 中的默认语言环境设置以使其保持一致?)

                    1. <tfoot id='4U4Mh'></tfoot><legend id='4U4Mh'><style id='4U4Mh'><dir id='4U4Mh'><q id='4U4Mh'></q></dir></style></legend>
                            <tbody id='4U4Mh'></tbody>
                        1. <small id='4U4Mh'></small><noframes id='4U4Mh'>

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