title: Spring Data JPA Query by Example Returns Null
body: <p>I have looked at numerous examples and tried various w/ &amp; w/o example matcher constraints but whatever I do my query by example only returns null.</p>
  
  <p>I am able to get the CRUD Repository data calls to work without any issues, however I extended that to the JPA Repository and added the QueryByExampleExecutor interface.  The findOne() does not seem to be working.</p>
  
  <p>Using Spring Boot 2.2.6.RELEASE, spring-boot-starter-data-jpa and mysql 5.7.</p>
  
  <p>When using query by example does the entire object need to be completed for matching? In other words, do all setters need the correct information? Or just the object data item that is to be matched?</p>
  
  <p>And Yes, the database does contain only one correct string on which I am attempting to match.</p>
  
  <p><strong>Customer</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@Entity
  @Table(name="customer")
  public class Customer {
      @Id
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      @Column(name="id")
      private long id;
  
      @Column(name="social_security_number")
      private String socialSecurityNumber;
  
      //Other data fields are included
  }
  </code></pre>
  
  <p><strong>CustomerRepository</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>import org.springframework.data.jpa.repository.JpaRepository;
  
  public interface CustomerRepository extends JpaRepository&lt;Customer, Long&gt; {
  }
  </code></pre>
  
  <p><strong>QueryByExampleExecutor</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>import java.util.Optional;
  
  import org.springframework.data.domain.Example;
  import org.springframework.data.domain.Page;
  import org.springframework.data.domain.Pageable;
  import org.springframework.data.domain.Sort;
  
  public interface QueryByExampleExecutor&lt;T&gt; {
  
      &lt;S extends T&gt; Optional&lt;S&gt; findOne(Example&lt;S&gt; example);
  
      &lt;S extends T&gt; Iterable&lt;S&gt; findAll(Example&lt;S&gt; example);
  
      &lt;S extends T&gt; Iterable&lt;S&gt; findAll(Example&lt;S&gt; example, Sort sort);
  
      &lt;S extends T&gt; Page&lt;S&gt; findAll(Example&lt;S&gt; example, Pageable pageable);
  
      &lt;S extends T&gt; long count(Example&lt;S&gt; example);
  
      &lt;S extends T&gt; boolean exists(Example&lt;S&gt; example);
  
  }
  </code></pre>
  
  <p><strong>CustomerService</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>public interface CustomerService {
      public Customer findBySSN(String ssn);
  }
  </code></pre>
  
  <p><strong>CustomerServiceImpl</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@Service
  public class CustomerServiceImpl implements CustomerService {
  
  private CustomerRepository customerRepository;
  
      @Autowired
      public CustomerServiceImpl(CustomerRepository theCustomerRepository) {
          customerRepository = theCustomerRepository;
      }
  
      @Override
      public Customer findBySSN(String ssn) {
          //Create a new object to use as a basis for querying against
          Customer customer = new Customer();
          //Set the parameters for the query
          customer.setSocialSecurityNumber(ssn);
          //Create an example query
          Example&lt;Customer&gt; customerExample = Example.of(customer);
  
          Optional&lt;Customer&gt; result = customerRepository.findOne(customerExample);
  
          if (result.isPresent()) { 
              return result.get();
          } else {
              // Didn't find the customer
              throw new ObjectNotFoundException("Customer", "Social Security Number ("+ssn+") not found...");
          }
      }
  }
  </code></pre>
  
  <p><strong>Calling Method</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>    @Autowired
      private CustomerService customerService;
  
  
      Customer ssnCustomer = customerService.findBySSN("123456789");
          if(ssnCustomer == null) {
              System.out.println("SSN NOT FOUND WAS NULL");
          } else {
              System.out.println("SSN FOUND "+ssnCustomer.getId());
          }
  </code></pre>
  
  <p>What am I missing?  Thank you in advance.</p>