title: how to use alias in querydsl?
body: <p>I am new to querydsl and already in love with it, but I can't get how to use an alias in this query.</p>
  
  <pre><code>    QProduct product = QProduct.product;
      JPQLQuery jPQLQuery = 
              from(product)
              .where(product.name.locate(searchTerm).as("score").gt(0).or(product.code.locate(searchTerm).as("score").gt(0))).groupBy(product.baseProd);
      List&lt;Product&gt; matchedNames = jPQLQuery.orderBy(new NumberPath&lt;Integer&gt;(Integer.class, "score").asc()).offset((pageNumber-1)*10).limit(10).list(product);
  </code></pre>
  
  <p>my first thought was something like this which throws an error with the generated query as:</p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException:
    org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token:
    as near line 3, column 31 [select product from
    mesoft.meshopframework.model.Product product where
    locate(?1,product.name) as score > ?2 or locate(?1,product.code) as
    score > ?2 group by product.baseProd order by score asc]</p>
  </blockquote>
  
  <p>could someone show me the coorect way to do this?? I hope it's not necessary for DB to calculate <code>product.name.locate(searchTerm)</code> or the other one again for sorting,</p>
  
  <p>thanks</p>