I'm running a Java system using SpringBoot and JPA , being event management and I have two entities: Inscricao
and HorarioAtividade
.
They have a Many To Many relationship, with my class Inscricao
having a list of HorarioAtividades
with the activities of each entry and Class HorarioAtividade
having a list of Inscriptions with the inscriptions of that activity.
The Inscricao
class also has a situacao
attribute that is of type enum
, eg.
SituacaoInscricao.RESERVADA
SituacaoInscricao.CONFIRMADA
SituacaoInscricao.AG_PAGAMENTO
When I make a findAll
in the repository of HorarioAtividade
, it automatically schedules activities with the list of subscriptions automatically through their relationship.
The problem I can not solve is:
I need to search all HorarioAtividade
of my base, only that is bringing only those subscriptions that are confirmed and waiting for payment.
I have tried with join fetch
, but it ends up mixing everything and the query is not correct.
I looked for Criteria api , but I did not understand how to solve my problem with it.