1

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
4

1 回答 1

0

对不起。我的方法findByEnabledOrCitiesContaining(boolean enabled, City city)是解决方案。它只是因为其他原因而不起作用。

所以,这个问题不需要更多的答案,可能会被关闭。

谢谢!

于 2016-05-31T19:27:01.523 回答