title: JPA query equals between two properties
body: <p>It is possible to compare two properties with JPA custom query ?</p>
  
  <p>Registration.java : </p>
  
  <pre><code>@Entity
  public class Registration implements Serializable {
  
  @Id
  @GeneratedValue(generator = "uuid")
  private UUID uuid;
  
  @ManyToOne(targetEntity=Entry.class)
  private Entry entry;
  
  @ManyToMany(targetEntity=Rate.class,fetch = FetchType.EAGER)
  private List&lt;Rate&gt; rate;
  
  @ManyToMany(fetch = FetchType.EAGER)
  private List&lt;Planning&gt; planning;
  
  }
  </code></pre>
  
  <p>Rate.java :</p>
  
  <pre><code>@Entity
  public class Rate implements Serializable {
  
  @Id
  @GeneratedValue(generator = "uuid")
  private UUID uuid;
  
  @ManyToOne
  private Activity activity;
  }
  </code></pre>
  
  <p>Planning.java :</p>
  
  <pre><code>@Entity
  public class Planning implements Serializable {
  
  @Id
  @GeneratedValue(generator = "uuid")
  private UUID uuid;
  
  @OneToOne
  private Location location;
  
  @OneToOne(fetch = FetchType.EAGER)
  private Coach coach;
  
  @OneToOne
  private Activity activity;
  </code></pre>
  
  <p>I would retrieve only rate.activity.id = planning.activity.id with something like :</p>
  
  <pre><code>public interface RegistrationDao extends CrudRepository&lt;Registration, UUID&gt; {
  
      findByPlanningAndRateActivityEqualsPlanningActivityOrderByEntryLastnameAsc(Planning planning);
  
   }
  </code></pre>
  
  <p>Thanks</p>