【问题标题】:Finding all entries where a collection field contains ALL of the given items查找集合字段包含所有给定项目的所有条目
【发布时间】:2018-06-18 00:59:20
【问题描述】:

所以我的问题与Finding all entries where a collection field contains any of the given items中的问题非常相似

除了而不是:

List<Message> findDistinctByTagsIn(Set<Tag> tag);

返回带有任何给定标签的所有消息,我想知道只返回包含所有给定标签的消息的查询语法。

【问题讨论】:

    标签: java spring spring-data-jpa


    【解决方案1】:

    如果您正在寻找ALL,您可以查看sql ALL 子句在互联网上的工作方式。然后,您可以在@Query 注释中将其定义为自定义查询,这样您就可以定义自己的 sql,如下所示

    @Query( "select t from Tags t where tag_ids =  all :ids" )
    List<Message> findAllDistinctByTags(@Param("ids") Set<Tag> tag);
    

    【讨论】:

      猜你喜欢
      • 2017-06-14
      • 1970-01-01
      • 1970-01-01
      • 2021-10-26
      • 2019-03-28
      • 1970-01-01
      • 2013-05-15
      • 2023-03-18
      相关资源
      最近更新 更多