title: Spring data JPA - Exclude ID column from one entity parameter
body: <p>I have two entities :</p>
  
  <pre><code>@Entity
  public class Car {
  
      @Id
      private Long id;
  
      @OneToOne
      private Engine engine;
  }
  </code></pre>
  
  <p>and the other one :</p>
  
  <pre><code>@Entity
  public class Engine {
  
      @Id
      private Long id;
  
      @Column
      private String value1;
  
      @Column
      private String value2;
  }
  </code></pre>
  
  <p>In my jpaRepositoy interface, i would like to do :</p>
  
  <pre><code>public interface CarRepository extends JpaRepository&lt;Car, Long&gt; {
  
      public Car findByEngine(Engine engine);
  }
  </code></pre>
  
  <p>But this method doesn't return my entity stored, because I created my Engine doing :</p>
  
  <pre><code>Engine engine = new Engine("someValue", "someValue");
  </code></pre>
  
  <p>without setting engine's id which is stored in database.</p>
  
  <p>So I would like to know if it is possible exclude a column like id ?
  If no, is the only way to do this is : </p>
  
  <pre><code>@Query("SELECT c FROM Car c WHERE c.engine.value1 = :value1 and c.engine.value2 = :value2")
  findByEngine(@Param("value1") String value1, @Param("value2") String value2)
  </code></pre>
  
  <p>?</p>
  
  <p><strong>Related question</strong> : If I have OneToMany relationship instead of OneToOne, like</p>
  
  <pre><code>@Entity
  public class Car {
  
      @Id
      private Long id;
  
      @OneToMany
      private List&lt;Engine&gt; engines;
  }
  </code></pre>
  
  <p>How can I do this request to have something like (still without id column) :</p>
  
  <pre><code>public Car findByEngines(List&lt;Engine&gt; engines);
  </code></pre>
  
  <p>Thanks a lot !</p>