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:
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();
dbo.old_remaining is my function and p_Vcode is an int
the error is:
unexpected token: ( near line 1, column 23 [from dbo.old_remaining(?)]
Second method:
Float var;
List li=session.getNamedQuery("{dbo.old_remaining(?)}")
.setString(1, var).list();
The error is: org.hibernate.MappingException: Named query not known: {dbo.old_remaining(?)}
Please Help me...