I have classes Country
and City
:
The Country
class has the properties:
@OneToMany(mappedBy = "country")
private Set<City> cities;
private boolean enabled;
Now I need to find all enabled countries together with the country containing a certain city:
Not this one:
findDistinctByEnabledOrCitiesNotNull(boolean enabled)
because in this case I find enabled countries together with all disabled countries containing cities.
I need something like:
findByEnabledOrCitiesContaining(boolean enabled, City city)
Is it possible?
SQL would be something like this:
select country.id, country.name, country.enabled from country
left join city on city.countryid = country.id
where country.enabled = 1 or city.id = 1