用于过滤掉 Java 中的空集合的 PostgreSQL 查询

PostgreSQL query to filter out an empty Collection in Java

而不是写作

.filter(tableADao -> tableADao.tableBDaos().isEmpty())

我正在寻找一个 postgreSQL 查询来删除空集合。我想我需要写一个连接,然后是 IS NOT EMPTY。这怎么写?

在table我有

@Id
@Column(name = "id_pop", nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToMany(mappedBy = "tableADao", cascade = CascadeType.ALL, orphanRemoval = true)
private Collection<TableBDao> tableBDaos = new ArrayList<>();

在Table B 我有

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "crr_pop_id", nullable = false)
private TableADao tableADao;

尝试

select * from A a 
where 0 < (select count(*) from B b where a.id_pop = b.crr_pop_id )