title: Spring Data JPA find by nested object id (nested twice)
body: <p>Is it possible?</p>
  
  <p>I'd like to get all AAA objects with a specific CCC.incidentAssessmentResultId id using JPARepository. Is it possible?</p>
  
  <pre><code>   @Entity
      @Table(schema = "aaa", name = "table")
      public class AAA {
  
          @Column(name = "kryterium")
          private String criterion;
  
          @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
          @JoinColumn(name = "id_kryterium_naruszen")
          private List&lt;BBB&gt; violationFactors;
  
      }
  
      public class BBB {
  
          @Column(name = "czynnik")
          private String factor;
  
          @Column(name = "stopien")
          private float degree;
  
          @JsonManagedReference
          @OneToOne(mappedBy = "violationFactor")
          private CCC incidentAssessmentFactor;
  }
  
  public class CCC {
  
      @Column(name="komentarz")
      private String comment;
  
      @Column(name="ocena_naruszenia_wynik_id", updatable=false, insertable=false)
      private Long incidentAssessmentResultId; //-&gt; I'd like to find AAA objects with a specific incidentAssessmentResultId ID
  
      @Column(name="czynnik_wybrany")
      private Boolean factorIsSelected;
  
      @Column(name = "wartosc_wybrana")
      private float value;
  
  
      @Repository
      public interface ViolationCriterionRepository extends JpaRepository&lt;AAA, Long&gt; {
  
      //  @Query("select vc from AAA vc left join vc.violationFactors vf left join vf.incidentAssessmentFactor iaf where iaf.incidentAssessmentResultId = ?1")
          List&lt;AAA&gt; findByViolationFactors_IncidentAssessmentFactor_IncidentAssessmentResultId(Long incidentId);
      }
  </code></pre>
  
  <p>Now, when I call ViolationCriterionRepository .findAll() I get all data but I want to get all data but with certain CCC objects. I've tried with the method below in my Repository but I get 0 results.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>My repo:</p>
  
  <pre><code>@Repository
  public interface ViolationCriterionRepository extends JpaRepository&lt;ViolationCriterion, Long&gt; {
  
      @Query("select vc from AAA vc join vc.violationFactors vf join vf.incidentAssessmentFactor iaf where iaf.incidentAssessmentResultId = ?1")
      List&lt;AAA&gt; findByIncidentAssessmentResultId(Long incidentId);
  }
  </code></pre>