title: Spring Data JPA: Query by Example?
body: <p>Using Spring Data JPA can I do a <a href="http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch17.html#querycriteria-examples" rel="noreferrer">query by example</a> where a particular entity instance is used as the search criteria?</p>
  
  <p>For example (no pun intended), if I have a <code>Person</code> entity that looks like:</p>
  
  <pre><code>@Entity
  public class Person {
    private String firstName;
    private String lastName;
    private boolean employed;
    private LocalDate dob;
    ...
  }
  </code></pre>
  
  <p>I could find all employed persons with a last name of Smith born on January 1, 1977 with an example:</p>
  
  <pre><code>Person example = new Person();
  example.setEmployed(true);
  example.setLastName("Smith");
  example.setDob(LocalDate.of(1977, Month.JANUARY, 1));
  List&lt;Person&gt; foundPersons = personRepository.findByExample(example);
  </code></pre>