title: Error with HQL QuerySyntaxException: unexpected token
body: <p>I have a query for 3 tables with HQL class. There are some one-to-many relationships.</p>
  
  <p>No problem with my database or with my entity classes for each..</p>
  
  <p>I have some class hibernate DAO that query, all work good except this one..</p>
  
  <p>class reportserviceimpl for jasperreport,</p>
  
  <p>I got error like this</p>
  
  <blockquote>
    <p>Exception in thread "AWT-EventQueue-0" org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ase near line 1, column 84 [select s.product.name as productName, sum(s.quantity) as quantity, s.sales.noTable ase noTable, s.sales.member as member, s.price as price, sum(s.subtotal) as subTotal from restodeskapp.model.SalesDetail s  where s.sales.id = :id  group by s.product.name order by s.product.name]
            at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)
            at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)
            at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
            at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:258)
            at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
            at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
            at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:77)
            at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:56)</p>
  </blockquote>
  
  <p>here my code for HBL</p>
  
  <pre><code>List&lt;SalesReport&gt; salesReports =
          sessionFactory.getCurrentSession()
          .createQuery("select s.product.name as productName,"
          + " sum(s.quantity) as quantity,"
          + " s.sales.noTable as noTable,"
          + " s.sales.member as member,"
          + " s.price as price,"
          + " sum(s.subtotal) as subTotal from SalesDetail s "
          + " where s.sales.id = :id "
          + " group by s.product.name order by s.product.name")
          .setParameter("id", id)
          .setResultTransformer(
          Transformers.aliasToBean(SalesReport.class))
          .list();
  </code></pre>
  
  <p>here my SalesReport</p>
  
  <pre><code>public class SalesReport {
      private String productName;
      private String member;
      private int noTable;
      private Long quantity;
      private BigDecimal subTotal;
      private BigDecimal price;
  //setter getter
  }
  </code></pre>
  
  <p>here my Sales</p>
  
  <pre><code>public class Sales implements Serializable{
  
      @Id @GeneratedValue
      @Column(name="ID")
      private Long id;
  
      @Column(name="NO_TABLE", nullable=false)
      private int noTable;
  
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name="SALES_DATE",nullable=false)
      private Date salesDate;
  
      @OneToMany(mappedBy="sales",cascade=CascadeType.ALL)
      @Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
      private List&lt;SalesDetail&gt; salesDetails;
  
      @Column(name="TOTAL_SALES",precision=18,scale=0,nullable=false)
      private BigDecimal totalSales;
  
      @ManyToOne
      @JoinColumn(name="Member_ID")
      private Member member;
  //setter getter
  }
  </code></pre>
  
  <p>here my salesdetail</p>
  
  <pre><code>public class SalesDetail implements Serializable{
  
      @Id @GeneratedValue
      @Column(name="ID")
      private Long id;
  
      @ManyToOne
      @JoinColumn(name="PRODUCT_ID",nullable=false)
      private Product product;
  
      @Column(name="QUANTITY",nullable=false)
      private Integer quantity;
  
      @Column(name="PRICE",nullable=false,precision=18,scale=0)
      private BigDecimal price;
  
      @Column(name="SUBTOTAL",nullable=false,precision=18,scale=0)
      private BigDecimal subtotal = BigDecimal.ZERO;
  
      @ManyToOne
      @JoinColumn(name="SALES_ID",nullable=false)
      private Sales sales;
  }
  </code></pre>
  
  <p>here my product</p>
  
  <pre><code>public class Product implements Serializable {
  
      @Id @GeneratedValue(strategy=GenerationType.AUTO)
      @Column(name="ID")
      private Long id;
      @Column(name="NAME",unique=true,length=200)
      private String name;
      @Column(name="DESCRIPTION",unique=false,length=500)
      private String description;
      @Column(name="PRICE",unique=false,length=200)
      private BigDecimal harga;
      @Column(name="note",unique=false,length=500)
      private String note;
      @Enumerated(EnumType.STRING)
      @Column(name="STATUS",length=20)
      private EnumStatus status;
      @Enumerated(EnumType.STRING)
      @Column(name="TYPE",length=20)
      private EnumJenisMakanan type;
      @Lob
      @Column(name="PICTURE")
      private byte[] picture;
  
  }
  </code></pre>
  
  <p>I realy dont know whares the wrong..
  please help..</p>
  
  <p>thanks you..
  Best regard :)</p>