• <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 - 集合表达式中的子查询

        时间:2024-08-23
          <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 - 集合表达式中的子查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Spring Data PageImpl 没有返回正确大小的页面? 下一篇:将 @EmbeddedId 与 JpaRepository 一起使用

                  相关文章

                  1. <tfoot id='4U4Mh'></tfoot><legend id='4U4Mh'><style id='4U4Mh'><dir id='4U4Mh'><q id='4U4Mh'></q></dir></style></legend>
                    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>