-->
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.  [ 5 posts ] 
Author Message
 Post subject: Sql-insert set the Parameters
PostPosted: Wed Jul 29, 2009 7:45 am 
Newbie

Joined: Wed Jul 29, 2009 7:37 am
Posts: 4
Hi All
this is my stored Proc
CREATE OR REPLACE PROCEDURE addNewUser(
UserId1 int,
UserName1 varchar2,
Password1 varchar2,
FirstName1 varchar2,
LastName1 varchar2
) AS
BEGIN
INSERT INTO TBL_USERS_TEMP (userid,username,password,firstname,lastname)
VALUES (UserId1,UserName1,Password1,FirstName1,LastName1);
END;


And this is my .hbm.xml file like this


<class name="AllFiles.Emp" table="EMP_SP">
<id name="id" column="userid">
<generator class="assigned"/>
</id>
<property name="username" column="USERNAME"/>
<property name="password" column="PASSWORD"/>
<property name="firstname" column="FIRSTNAME"/>
<property name="lastname" column="LASTNAME"/>
<sql-insert callable="true">{call addNewUser(:id,:username,:pass,:first,:last)</sql-insert>
</class>

In java class


how to call SP using set the parameters .I use like this But it's giving error

Query query=session.getNamedQuery("addNewEmp");
query.setParameter("id",new Integer(45));
query.setParameter("username","sanjeev");
query.setParameter("pass","sanjeev");
query.setParameter("first","sanjeev");
query.setParameter("last","yadav");
query.executeUpdate();


Please help me out .How to call SP using Sql-insert

Thanks
Sanjeev Thummala


Top
 Profile  
 
 Post subject: Re: Sql-insert set the Parameters
PostPosted: Wed Jul 29, 2009 7:48 am 
Newbie

Joined: Wed Jul 29, 2009 7:37 am
Posts: 4
Sorry For Above Mistake


I used Query query=session.getNamedQuery("addNewUser"); //Replace with Named Query "addNewEmp"


Top
 Profile  
 
 Post subject: Re: Sql-insert set the Parameters
PostPosted: Wed Jul 29, 2009 3:37 pm 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
Custom sql-insert, update or delete are for session.save(), session.update() and session.delete() operations not for query.

Code:
Emp emp = new Emp();
emp.setUserName(userName);
...
session.save(emp);


Christophe


Top
 Profile  
 
 Post subject: Re: Sql-insert set the Parameters
PostPosted: Wed Jul 29, 2009 4:29 pm 
Beginner
Beginner

Joined: Wed Jul 29, 2009 3:43 pm
Posts: 22
Which database are you using?


Top
 Profile  
 
 Post subject: Re: Sql-insert set the Parameters
PostPosted: Tue Aug 04, 2009 8:16 am 
Newbie

Joined: Wed Jul 29, 2009 7:37 am
Posts: 4
Hello guys,
sorry for late reply
Iam using Oracle9i


May i know how to set the parameters in stroed Proc when i use only insert stroed Proc.

How to call that Insert stored Prc
will u please give any sample very help full for me


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

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.