title: how to call a sql server function from hibernate with return parameter?
body: <p>I have a function in SQL server and I want to call it from hibernate.
  I have tested these 2 methods but no one was successful.
  First method:</p>
  
  <pre><code>Session sixSession=HibernateUtil.getSessionFactory().openSession();
  Query q2=sixSession.createQuery("from dbo.old_remaining(?)").setParameter("paymentVcode", p_Vcode);
          q2.getNamedParameters();
          List list=sixSession.getNamedQuery("{dbo.old_remaining(?)}").setString(1,"p_Vcode").list();
  </code></pre>
  
  <p>dbo.old_remaining is my function and p_Vcode is an int</p>
  
  <p>the error is:</p>
  
  <pre><code>unexpected token: ( near line 1, column 23 [from dbo.old_remaining(?)]
  </code></pre>
  
  <p>Second method:</p>
  
  <pre><code>Float var;
  List li=session.getNamedQuery("{dbo.old_remaining(?)}")  
      .setString(1, var).list();
  </code></pre>
  
  <p>The error is:
  org.hibernate.MappingException: Named query not known: {dbo.old_remaining(?)}</p>
  
  <p>Please Help me...</p>