title: Calling a SQL sever stored procedure using hibernate
body: <p>I am trying to call SQL Server stored procedure using createSQLQuery method in hibernate ,but getting exception.please help as i am new to hibernate.</p>
  
  <p>Exception:</p>
  
  <pre><code>   org.hibernate.exception.SQLGrammarException: could not execute query
  </code></pre>
  
  <p>SQL Server Stored Procedure-</p>
  
  <pre><code>  CREATE PROCEDURE [dbo].[sqlServerProc]
    (@SOURCE_AID NUMERIC(18,0),
    @DESTI_BID NUMERIC(18,0),
    @E_CID NUMERIC(18,0),
    @MOVE_DID BIT,
    @RST_ADDED VARCHAR(MAX) = '' OUTPUT,
    @LST_ADDED VARCHAR(MAX) = ''  OUTPUT,
    @PST_ADDED VARCHAR(MAX) = '' OUTPUT,
    @IS_VALUE BIT = 0 OUTPUT
   )     
  </code></pre>
  
  <p>HIBERNATE CODE:</p>
  
  <pre><code> public String Function(String AId,String BId,String CId,String DID ) throws Exception
  { 
  
  try{
              session = getSessionFactory().openSession();
              session.beginTransaction();
              Query query = session.createSQLQuery(
              "CALL sqlServerProc(:AId,:BId,:CId,:DID)").setParameter("AId",  AId).
              setParameter("BId", BId).
              setParameter("CId", CId).
              setParameter("DID", DID).
              ;
  
              ListOfEnvData=  query.list();
  
              for (Object[] aRow :ListOfEnvData) {
  
                  String a = (String) aRow[0];
                  String b = (String) aRow[1];
                  String c = (String) aRow[2];
                  String d = (String) aRow[3];
                  System.out.println("a"+a+"b"+b+"c"+c+"d"+d);
              //  value=d;
                  break;
               }
  
  
            }catch(Exception e){
                session.close();
                e.printStackTrace();
  
            }}
  </code></pre>