如何将此 java 过滤器转换为 PostgreSQL 查询?

How can I convert this java filter into a PostgreSQL query?

我有下面的 java 流功能,但我想使用 PostgreSQL 查询来检索相同的信息,执行过滤器并在可能的情况下收集到列表中。我想在 repo 层中写一个查询,例如 @Query("") 但不确定要写什么。 Table 名称为 pop_responder,列名称为 pop_registrants

    public List<PopResponderDao> getAllPopResponders() {
    return popResponderRepository
        .findAll()
        .stream()
        .filter(responderDao -> responderDao.getPopRegistrationDaos().isEmpty())
        .collect(Collectors.toList());
}

PopRegistrationDaosCollection<PopRegistrationDao> 类型。存储库层使用 JPA:

public interface PopResponderRepository extends JpaRepository<PopResponderDao, Long> {}

目前不支持使用流与数据库交互。

如果您只需要过滤数据,您可以使用 JPQL 查询。 filter 基本上是 JPQL 中的 WHERE 子句。

SELECT p FROM PopResponderDao p where p.popRegistrationDaos IS NOT EMPTY