-->
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.  [ 6 posts ] 
Author Message
 Post subject: How to execute this stored procedure(new to hibernate)
PostPosted: Tue Jun 20, 2006 10:05 am 
Newbie

Joined: Tue Jun 20, 2006 8:27 am
Posts: 1
Location: India
Hello All.... I need to execute this stored procedure using hibernate. I am new to hibernate and need to know what would be the exact steps to execute this very basic stored procedure.

The procedure takes two parameters and outs two parameters:

CREATE OR REPLACE procedure SAMPLE_PROC (P_PARA1 number, P_PARA2 varchar2, P_PARA3 OUT number, P_PARA4 OUT varchar2)
as
begin
P_PARA3:=P_PARA1+10;
P_PARA4:=P_PARA2||'10';
end;
/

Please help.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 20, 2006 11:04 am 
Newbie

Joined: Mon Jun 19, 2006 2:34 pm
Posts: 8
I am new to Hibernate as well so maybe I just haven't thought it through all the way, but is there even any benefit to running a stored procedure with Hibernate?? I can't really think of one...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 29, 2006 1:28 pm 
Beginner
Beginner

Joined: Thu Jun 29, 2006 12:36 pm
Posts: 20
Hi I think a good starting point for you would be one of the last posts of this thread by oldkeybo :

http://forum.hibernate.org/viewtopic.php?t=960553

to pass parameters to your procedure you need to change this line in the mappping file:


Code:
{ call myDepartName() }

into
Code:
{ call myDepartName(?,?) }


and in your launching code you should have something like this:
Code:
session.getNamedQuery("YourStoredProcedure")
                      .setParameter(0,value1);


Hope this helps.
Peter


Last edited by Pi on Thu Jun 29, 2006 2:11 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: I think
PostPosted: Thu Jun 29, 2006 1:59 pm 
Regular
Regular

Joined: Wed Feb 22, 2006 11:28 am
Posts: 65
Location: Santiago, Chile
You can read in more detail about Hibernate Document Reference.

At here, I will show you a example:

<sql-query name="IndiceHistoricoMercado" callable="true">
<return-scalar column="" type="string"/>
call SAMPLE_PROC :var1, :var2, :var3, :var4
</sql-query>

The sentence mentioned is include in some your hibernate mappings files.

Then, do someting with what Pi sayed to you, call NamedQuery then set all variables you need, and so on.

Waiting for your good result.

_________________
If you called Wisdom, please help to all to solve theirs problems.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 29, 2006 2:23 pm 
Beginner
Beginner

Joined: Thu Jun 29, 2006 12:36 pm
Posts: 20
Hi neketsushonen:

I tried to call the procedure in your way but it didn't work. I had to put the variables into paranthesis:
call SAMPLE_PROC (:var1)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 29, 2006 2:25 pm 
Regular
Regular

Joined: Wed Feb 22, 2006 11:28 am
Posts: 65
Location: Santiago, Chile
Pi wrote:
I tried to call the procedure in your way but it didn't work. I had to put the variables into paranthesis:
call SAMPLE_PROC (:var1)


So, that did work fine now?

_________________
If you called Wisdom, please help to all to solve theirs problems.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.