title: How to execute a sql stored procedure from Java Hibernate using Session Factory?
body: <p>I am unable to call my stored procedure from java hibernate using session factory</p>
  
  <p>I have written a sql procedure which takes 5 parameters and return a result set which works fine in MS SQL studio</p>
  
  <pre><code>EXEC SlaGrid @appID=245,@fromYear=2012,@toYear=2013,@fromMon=1,@toMon=12   --- sql
  
  EXEC SlaGrid @applID=:applID,@fromYear=:fromYear,@toYear=:toYear,@fromMon=:fromMon,@toMon=:toMon  --hibernate
  </code></pre>
  
  <p>i am setting the parameters for the above query</p>
  
  <pre><code>String queryString = "EXEC SlaGrid @applID=:applID,@fromYear=:fromYear,@toYear=:toYear,@fromMon=:fromMon,@toMon=:toMon"
  
  Query query = sessionFactory.getCurrentSession().createSQLQuery(queryString);
  
  //set query parameters here
  
  query.list()    --- giving sql grammer exception
  </code></pre>