title: JPA: How to search by property expressions in `oneToMany` and `manyToMany` relations?
body: <p>I want to fetch the parent object data based on child search criteria.</p>
  
  <p>The User Entity class looks like this:</p>
  
  <pre><code>@Entity
  @Table(name = "user")
  public class User
  {
      protected String usertId;
      protected Collection&lt;Contact&gt; contacts;
  
      @OneToMany
      @JoinColumn(name="user_id", referencedColumnName="user_id")
      public Collection&lt;Contact&gt; getContacts()
      {
          return contacts;
      }
  
      //getters &amp; setters
  
  }
  </code></pre>
  
  <p>And its child class </p>
  
  <pre><code>@Entity
  @Table(name = "contact")
  public class Contact
  {
      protected String phoneNumber;
      protected String zipCode;
  
  
      //getters &amp; setters
  
  }
  </code></pre>
  
  <p>And the <code>UserRepository</code> class is:</p>
  
  <pre><code>@Repository
  public interface UserRepository extends JpaRepository&lt;User, Long&gt; {
  
      User findByZipCode(String zipCode);
  
  }
  </code></pre>
  
  <p>I am trying to get all the user based on e.g. zip code but this giving below compilation error.</p>
  
  <p>Invalid derived query! No property zipCode found for type User!</p>
  
  <p>Can some help me with this or any sample tutorial on how to fetch records using  child fields</p>