title: Varchar to int typecasting in JPA 1.9
body: <p>I want to convert varchar to int in jpql. The field is varchar, but all the data will be in integer format only. My JPA library version is 1.9</p>
  
  <p>I already used CAST and CONVERT methods, but it did not working.</p>
  
  <p>My query is: </p>
  
  <pre><code>select SUM(Cast(model.wagonsRequired as INT)) from IptRailcargolines model where model.iptRailwayindent.id=7
  </code></pre>
  
  <p>or</p>
  
  <pre><code>select SUM(CONVERT(INT, model.wagonsRequired)) from IptRailcargolines model where model.iptRailwayindent.id=7
  </code></pre>
  
  <p>and my java console error is:</p>
  
  <pre><code>Caused by: Exception [TOPLINK-8025] (Oracle TopLink Essentials - 2.0 (Build b40-rc (03/21/2007))): oracle.toplink.essentials.exceptions.EJBQLException
  Exception Description: Syntax error parsing the query [select SUM(FUNCTION(CONVERT(INT, model.wagonsRequired))) from IptRailcargolines model where model.iptRailwayindent.id=:headId], line 1, column 20: unexpected token [(].
  Internal Exception: line 1:20: unexpected token: (
  </code></pre>
  
  <p>Please help me to resolve the issue.</p>
  
  <p>Thankyou for your reply...</p>
  
  <p>I am using MyEclipse IDE. So, may be internally it will use the Eclipselink. Can you please tell me where can i found my EclipseLink version? and how can i use FUNC / FUNCTION method in my JPA query. (I am using SQLSERVER 2008.)</p>
  
  <p>I think i found the eclipseLink version in my myeclipse. 
  Windows > Preference > JPA</p>
  
  <p>The version is 1.0</p>
  
  <p>Please tell me the solution.</p>