title: Query a database table using a foreign key ( where) using Hibernate
body: <p>i m new to hibernate, so the question might look stupid.</p>
  
  <p>I have the two tables: </p>
  
  <p><strong><em>Application:</em></strong></p>
  
  <pre><code>@Entity
  @Table
  public class Application extends BaseSimpleEntity {
      @Column(nullable = false)
      private String appID;
      @OneToOne(cascade = CascadeType.ALL)
      @Searcheable
      private LocalizedString name;
  ...
  </code></pre>
  
  <p><strong><em>Compilation:</em></strong></p>
  
  <pre><code>@Table
  @Entity
  public class Compilation extends BaseSimpleEntity {
  
      @Column(nullable = false)
      private String uid;
      @ManyToOne
      private Application application;
      @Column
      private DateTime creationDate;
      @Column
      private DateTime finishDate;
      @Column
      private String path;
  ....
  </code></pre>
  
  <p>and i want to get a list of Compilation that matches a given Application.</p>
  
  <p>i did the following query: </p>
  
  <pre><code>@Query("FROM Compilation c WHERE c.Application.id = :applicationId")
  List&lt;Compilation&gt; findValidCompialiton(@Param("applicationId") Long applicationId);
  </code></pre>
  
  <p>But it is not working.</p>
  
  <p><strong><em>Error:</em></strong></p>
  
  <blockquote>
    <p>Caused by: org.hibernate.QueryException: could not resolve property:
    Application of: xx.xx.xx.xx.xx.Compilation [FROM
    xx.xx.xx.xx.xx.Compilation c WHERE c.Application.id = :applicationId]
      at
    org.hibernate.QueryException.generateQueryException(QueryException.java:137)
      at
    org.hibernate.QueryException.wrapWithQueryString(QueryException.java:120)
      at
    org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:234)
      at
    org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)
      at
    org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:126)
      at
    org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:88)
      at
    org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:190)
      at
    org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)
      at
    org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236)
      at
    org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800)
      at
    org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:328)</p>
  </blockquote>