Instead of writing
.filter(tableADao -> tableADao.tableBDaos().isEmpty())
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?
In table A I have
@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<>();
In Table B I have
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "crr_pop_id", nullable = false)
private TableADao tableADao;
CodePudding user response:
Try
select * from A a
where 0 < (select count(*) from B b where a.id = b.tableADao )