title: How can I get List of nested objects using JpaRepository?
body: <p>I am unable to to get a list of nested objects using a <code>JpaRepository</code>. I'll try to explain what I want using the following code:</p>
  
  <p><strong>AutoService</strong> entity:</p>
  
  <pre><code>@Entity
  public class AutoService {
      @Id
      private long id;
  
      @Column(name = "serviceName", nullable = false)
      private String serviceName;
  }
  </code></pre>
  
  <p><strong>Service</strong> entity:</p>
  
  <pre><code>@Entity
  public class Service {
      @Id
      private long serviceId;
  
      @Column(name = "serviceName", nullable = false)
      private String serviceName;
  
      @Column(name = "category", nullable = false)
      private String category;
  
      @ManyToOne
      @JoinColumn(name = "autoServiceId", nullable = false)
      private AutoService autoService;
  }
  </code></pre>
  
  <p><strong>ServiceRepository</strong> interface:</p>
  
  <pre><code>public interface ServiceRepository extends JpaRepository&lt;Service, Long&gt; {
      List&lt;Service&gt; findByServiceNameAndCategory(String autoServiceName, String categoryName);
  }
  </code></pre>
  
  <p>Business logic:</p>
  
  <pre><code>@org.springframework.stereotype.Service
  public class ServiceServiceImpl implements ServiceService {
      @Autowired
      private ServiceRepository serviceRepository;
  
      @Override
      public List&lt;Service&gt; findByAutoServiceAndCategory(String autoServiceName, String serviceCategory) {
          return serviceRepository.findByServiceNameAndCategory(autoServiceName, serviceCategory);
      }
  }
  </code></pre>
  
  <p>As I am expecting, the code above is unable to provide the desired list of <code>Service</code>s matching the provided category and <code>AutoService</code> names.</p>
  
  <p>Can someone provide advice on how should I use my repository to get list of nester services by: <code>autoServiceName</code> and <code>serviceCategory</code> please?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>Right now I am using the custom query. </p>
  
  <p>I am using autoServiceId instead of service name right now.</p>
  
  <p>But for some reason I am getting empty list of objects.</p>
  
  <p>Here is my JPA Repo. </p>
  
  <pre><code>public interface ServiceRepository extends JpaRepository&lt;Service, Long&gt; {
      @Query("SELECT s from Service s where s.autoService.id  = :autoServiceId and s.category = :categoryName")
      List&lt;Service&gt; findByServiceNameAndCategory(@Param("autoServiceId") Long autoServiceId, @Param("categoryName") String categoryName);
  }
  </code></pre>
  
  <p>Any suggestions please ?</p>
  
  <p>I think i know the answer. Problem in my category, sended to the server. I wrote it on Russian language. And encoding broken value of category on server side.
  <a href="https://i.stack.imgur.com/RzuHR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RzuHR.png" alt="enter image description here"></a></p>