title: PostgreSQL query to filter out an empty Collection in Java
body: <p>Instead of writing</p>
  <pre><code>.filter(tableADao -&gt; tableADao.tableBDaos().isEmpty())
  </code></pre>
  <p>I'm looking to write a postgreSQL query to remove the empty collection. I think I need to write a join followed by IS NOT EMPTY. How can this be written?</p>
  <p>In table A I have</p>
  <pre><code>@Id
  @Column(name = &quot;id_pop&quot;, nullable = false)
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Long id;
  
  @OneToMany(mappedBy = &quot;tableADao&quot;, cascade = CascadeType.ALL, orphanRemoval = true)
  private Collection&lt;TableBDao&gt; tableBDaos = new ArrayList&lt;&gt;();
  </code></pre>
  <p>In Table B I have</p>
  <pre><code>@ManyToOne(cascade = CascadeType.ALL)
  @JoinColumn(name = &quot;crr_pop_id&quot;, nullable = false)
  private TableADao tableADao;
  </code></pre>