I have an @Entity Location
which has a field :
Set<Alert> openAlerts
Then I have an @Entity Alert
which has two fields :
AlertState state
which is an enum (can beOPEN
orCLOSED
)Location originatedIn
which is the location where the alert originated.
At the moment in Location
I have :
@OneToMany(mappedBy = "originatedIn")
@JsonIgnoreProperties({"originatedIn"})
private Set<Alert> openAlerts;
It retrieves all the alerts linked to the location (open or closed).
I want to replace that field with Integer numberOpenAlerts
.
This new field should retrieve and count only the alerts linked to the location that have the AlertState
of OPEN
.
How can I do that ?