title: How to write that HQL right
body: <p>Hi I am trying to write this where and fetch query and I get an error</p>
  
  <pre><code> Query query = session.createQuery("from Device d where d.customerRefId=:customerId " +
                      "left join fetch d.tradeInOldDevice ");                    
    query.setParameter("customerId", "myId");  
   Set&lt;Device&gt; customerDevices= (Set&lt;Device&gt;) query.list();
  </code></pre>
  
  <p>the error:</p>
  
  <pre><code>2013-09-24 12:18:45,753 ERROR PARSER:56 - line 1:98: unexpected token: left
  </code></pre>
  
  <p>Thats Device entity:</p>
  
  <pre><code>@Entity
  @Table(name = "Devices")
  public class Device implements Serializable, IHidingDeletable {
  
  ...
  
    @ManyToOne(optional = true,fetch=FetchType.LAZY)
      private Customer owningCompany
  
   @OneToOne(fetch=FetchType.LAZY)
      @JoinColumn(name = "tradeInOldDevice")
      @Cascade(CascadeType.ALL)
      private Device tradeInOldDevice;
  
  ..
  </code></pre>
  
  <p>And That's Customer:</p>
  
  <pre><code>public class Customer extends AbstractCustomer {...}
  
  
  @Entity
  @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
  @Table(name = "Customers")
  @DiscriminatorColumn(name = "type")
  public abstract class AbstractCustomer implements IVersionized, Serializable {
  
     @Id
      protected String customerRefId;
  </code></pre>
  
  <p>Any idea?</p>