title: Spring Data JPA: find nested object
body: <p>I have a LOCATION entity and it contains COUNTRY, STATE and CITY. And I have a LocationRepository interface defined as:</p>
  
  <pre><code>public interface SpringDataLocationRepository extends LocationRepository,
          Repository&lt;Location, Integer&gt; {
  }
  </code></pre>
  
  <p>I want to find all the state by country. I can follow the method name standard to query everything for LOCATION entity. If I want List, do I need to create StateRepository interface and query everything about STATE in there? If I can just get it from LocationRepository, what's the method looks like? I assume it will look something like below (of course it doesn't work).</p>
  
  <p>List findStateByCountryCountryId(Integer id) throws DataAccessException;</p>