Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java SpringJPA存储库,从参数列表中选择包含所有元素的数据_Java_Spring_Hibernate_Spring Data_Spring Data Jpa - Fatal编程技术网

Java SpringJPA存储库,从参数列表中选择包含所有元素的数据

Java SpringJPA存储库,从参数列表中选择包含所有元素的数据,java,spring,hibernate,spring-data,spring-data-jpa,Java,Spring,Hibernate,Spring Data,Spring Data Jpa,我有spring JPA存储库界面: public interface ElementLogRepository extends JpaRepository<ElementLog, String> public interface ElementLogRepository扩展了JpaRepository 有一个问题: @Query("SELECT pl.element.id FROM ElementLog pl WHERE pl.tags IN :tags)") public

我有spring JPA存储库界面:

public interface ElementLogRepository extends JpaRepository<ElementLog, String> 
public interface ElementLogRepository扩展了JpaRepository
有一个问题:

@Query("SELECT pl.element.id FROM ElementLog pl WHERE pl.tags IN :tags)")
public List<ElementLog> findLatestElementLogsByTags(@Param("tags") List<Tag> tags);
@Query(“从ElementLog pl中选择pl.element.id,其中pl.tags位于:tags中)”)
公共列表findLatestElementLogsByTags(@Param(“标记”)列表标记);
当我调用方法
findLatestElementLogsByTags
时,我收到所有
ElementLog
,其中包含
列表标记中的任何标记

如何修改查询以获取包含
列表标记中所有标记的所有
元素日志


首先,我认为ElementLog和Tag与OneToMany有关

SELECT log FROM ElementLog log WHERE log.id IN (
     SELECT DISTINCT pl.id FROM ElementLog pl join pl.tags as t where t in :tags group by pl.id having count(pl.id) == :tags.size()
)

我的想法是,与匹配大小相比,hql应该是正确的,我没有实际运行过。

因此基本上不是使用单个标记的
ElementLog
列表,而是使用包含所有标记的单个
ElementLog