What is the most efficient way to filter a Pojo's OneToMany field retrieved in a JpaSpecification findAll?

47 Views Asked by At

I am using the JpaSpecification to get a list of filtered ProfileEntity. ProfileEntity has a @OneToMany List<Channel> channels field. Each of the ProfileEntitys will have 5 Channels associated with it but I want my findAll(Specification<ProfileEntity> spec) to return a list of only 1 Channel (based on the included Language which is part of Channel's composite key)

Ideally I would like to leverage the existing JpaSpecification logic but I am not sure if it's possible to filter the ProfileEntity's fields in the same way that I filter ProfileEntity itself. I have been unable to find any relevant queries and my attempts to do so have been fruitless.

Either way, what's the most efficient way to make the findAll(Specification<ProfileEntity> spec)method returns all ProfileEntitys with only 1 associated Channel

0

There are 0 best solutions below