title: Hibernate HQL for joining non-mapped tables
body: <p>I have an entity called "Kurs":</p>
  
  <pre><code>@Entity
  public class Kurs {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private long kursId;
      private String name;
      //Accessors....
  }
  </code></pre>
  
  <p>And also an entity called "Kategori":</p>
  
  <pre><code>@Entity
  public class Kategori {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private long kategoriId;
      private String name;
  
      @ManyToMany(cascade = CascadeType.ALL)
      @JoinTable (name = "KursKategori", joinColumns = {@JoinColumn(name = "kategoriId")}, inverseJoinColumns = {@JoinColumn(name = "kursId")})
      private List&lt;Kurs&gt; kursList;
      // Accessors....
  }
  </code></pre>
  
  <p>Now I'm building a <code>KursDao</code> that will have a method to fetch a list of <code>Kurs</code> by the <code>kategoriId</code>, but I'm unable to get the join to work for me.
  Being used to SQL, I would normally think the query should be like this:</p>
  
  <pre><code>getHibernateTemplate().find("from Kurs as k INNER JOIN KursKategori kk ON k.kursId = kk.kursId AND kk.kategoriId = ?", kategoriId);
  </code></pre>
  
  <p>But this doesn't work and I can't get anything like this to work. I do not want to create a class of the <code>KursKategori</code> since it is only a mapping table anyway.
  Is there a way to join the non-mapped table <code>KursKategori</code> to the mapped table <code>kurs</code> so that I will only get the <code>Kurs</code> that is in the correct <code>Kategori</code>?</p>