Hi All I created One Stored Proc to retrive the records fron one table is as follwos CREATE OR REPLACE PROCEDURE SPaddNewUser1(name in varchar2,sal in varchar2,p_cursor out SYS_REFCURSOR) AS BEGIN open p_cursor for select id,name,sal from USER_SANJEEV; //here user_sanjeev is table name END;
In Hbm.xml file i configure like this <hibernate-mapping> <class name="DataBaseConnectivity.User" table="USER_SANJEEV"> <id name="id"> <column name="id"/> <generator class="increment"/> </id> <property name="name"> <column name="NAME"/> </property> <property name="sal"> <column name="SAL"/> </property> </class> <sql-query name="addNewUser_SP" callable="true"> <return class="User"> <return-property name="id" column="ID"/> <return-property name="name" column="NAME"/> <return-property name="sal" column="SAL"/> </return> {call SPaddNewUser1(:name,:sal,?)} // i will pass here name and sal arguments </sql-query>
Now i called getNamedQuery from here List result = session.getNamedQuery("addNewUser_SP").setParameter("name","ravi").setParameter("sal",1000).list(); //step 6 for(int i=0; i<result.size(); i++) {
User user = (User)result.get(i); System.out.println("User Name is "+ user.getName()); System.out.println("User Salary is "+ user.getSal()); }
But it is not calling step 6 .It was not give any error but process stops over here .May i knw where i was wrong.
Actually there is no need to pass the arguments to the strored Proc .Just for sample i used it .
|