-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: <sql-query> calling stored Proc
PostPosted: Thu Aug 06, 2009 2:56 am 
Newbie

Joined: Wed Jul 29, 2009 7:37 am
Posts: 4
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 .


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.