I'm using Spring data (jpa-repository) and I have the following entities:
public class City{
....
private Street street;
....
}
public class Street{
...
private List<Building> buildings;
...
}
public class Building{
...
private List<Flat> flats;
....
}
public class Flat{
...
private boolean lightsOn;
...
}
I want to create a query to get all (distinct) cities that has at least one flat with powered on lights.
I tried this query:
@Query("select distinct c from Cities c where c.street.buildings.flats.lightsOn = true")
but got this error message:
The state field path 'c.street.buildings.flats.lightsOn' cannot be resolved to a valid type.
How can I do that?