title: HQL select Exception on Invalid path
body: <p>I am trying to issue a select from database using HQL</p>
  
  <p>here is the code:</p>
  
  <pre><code>public Collection&lt;Link&gt; getAllLinksForDevice(Device device) {
      Session session = sessionFactory.getCurrentSession();
      String hql = "SELECT Link as l WHERE l.device1 = :deviceId OR l.device2 = :deviceId";
      Query query = session.createQuery(hql); &lt;-- Fails here!!
      query.setParameter("deviceId",device.getId());
      Collection&lt;Link&gt; linkList  = query.list();
      return linkList;
  }
  </code></pre>
  
  <p>and the link entity:</p>
  
  <pre><code>@Id
  @Column(name = "id")
  @GeneratedValue
  private int id;
  
  @ManyToOne
  @JoinColumn(name="device1_id")
  private Device device1;
  
  @ManyToOne
  @JoinColumn(name="device2_id")
  private Device device2;
  </code></pre>
  
  <p>The device Entity:</p>
  
  <pre><code>@Entity
  @Table(name = "device")
  public class Device {
  
      @Id
      @Column(name = "id")
      @GeneratedValue
      private int id;
  
      @Column(name = "dns_Name")
      private String dnsName;
  
      @Column(name = "ip_address_v4")
      private String ipV4;
  
      @Column(name = "device_type")
      private int deviceType;
  
      @ManyToOne
      @JoinColumn(name="area_id")
      private Area area;
  </code></pre>
  
  <p>But I get an exception:</p>
  
  <blockquote>
    <p>15:10:55,570 DEBUG ErrorCounter:51 - :0:0: unexpected end of subtree
    :0:0: unexpected end of subtree
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3117)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:720)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:571)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:288)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:231)
        at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)
        at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)</p>
  </blockquote>
  
  <p>and:</p>
  
  <blockquote>
    <p>15:10:55,622 ERROR PARSER:56 -  Invalid path: 'l.device1'
    15:10:55,628 DEBUG ErrorCounter:51 -  Invalid path: 'l.device1'
     Invalid path: 'l.device1'
        at org.hibernate.hql.ast.util.LiteralProcessor.lookupConstant(LiteralProcessor.java:135)
        at org.hibernate.hql.ast.tree.DotNode.resolve(DotNode.java:216)
        at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:117)
        at org.hibernate.hql.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:113)
        at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:854)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1293)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4243)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3722)</p>
  </blockquote>