title: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: LEFT near line 1, column 24
body: <p>I am trying to query data from database,but I wanna to remove the last three chars of specific column. The SQL is effective in SQL SERVER but when I put it into hibernate's syntax, eclipse showed as the title, the SQL context as follows:</p>
  
  <pre><code>String sql = "select distinct d.code,LEFT(d.VILLAGE, (LEN(d.VILLAGE)-3)) as village_name from DistrictInfo d where d.county=:region and d.town=:town and LEN(d.VILLAGE) !=0";
  Query q = session.createQuery(sql);
  q.setString("region", region);
  q.setString("town", town)
  </code></pre>
  
  <p>The Specific exception as follows :</p>
  
  <pre><code>org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: LEFT near line 1, column 24 [select distinct d.code,LEFT(d.VILLAGE, (LEN(d.VILLAGE)-3)) as village_name from org.nergis.orm.model.DistrictInfo d where d.county=:region and d.town=:town and LEN(d.VILLAGE) !=0]
  </code></pre>
  
  <p>Does the <code>LEFT()</code> cause the exception? How can I make it right?</p>