Sprig Data 派生方法名称 "parameter in collection attribute"

Sprig Data derived method name with "parameter in collection attribute"

我有这个 JPA 实体

@Entity @Table(name = "Todos")
public class Todo {
    @Id @GeneratedValue
    private Long id;
...
    @CollectionTable(name = "Doers", joinColumns = @JoinColumn(name = "id"))
    @ElementCollection(targetClass = String.class, fetch = FetchType.EAGER)
    @NotEmpty
    private final Set<String> doers = new HashSet<>();  // emails
    @Email
    private String owner;
}

我需要我的 JpaRepository 为我获取所有待办事项实例,当特定的执行者附加到它们时。

即Iterable findAllByDoersContaining(String email) // 集合扫描

我会说,这与 findByOwnerIn(Collection doers) 完全相反。 是否有可能实现该连接?

感谢您的提示。

所以我最终实现了自己的查询:

@Query(value = "SELECT * FROM Todos t WHERE EXISTS (SELECT d.ID FROM Doers d WHERE d.ID = t.ID AND d.DOERS = :email)",
       nativeQuery = true)
Streamable<Todo> findAllByAssigneesContaining(@Param("email") String email);