Well, calling SP's is not a Struts topic (don't care the version), of course 
it's for Hibernate or even Oracle!!

Also, it has a lot to do with your persistence layer and Data Model design.

Anyway, you have several ways to call an Oracle SP function, here you have two 
hints:

a) Use Hibernate to map the SP using named query, as it is explained at 
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#sp_query
and follow as you know.

b) Use standard code to call the SP and manage the return, something like this:
.....
String errors = null;
Connection con = myPersistence.getSession().connection();          
try {
        CallableStatement cs = null; //a "simple" CallableStatement
        // now a call to the function with two parameters
        cs = con.prepareCall("{? = call PKG_VALIDATIONS.FNC_VALID1(?,?)}");
        
        cs.registerOutParameter(1,Types.VARCHAR); //the type of return
        cs.setInt(2,2007);                              //the first param (a 
Int)
      cs.setString(3,"Agust");                  //the second param
      cs.execute();                                     //execute the call
      errors = cs.getString(1);                 //get the result
    }
.....

Of course it's a very small a simple example to validate some data using a 
Oracle SP function, and returning the errors found (if any) as a string.

Well, just take care what you are returning and how are you waiting the return 
in your call. Of course, there some limitations on what you can return from 
Oracle SP function and what you can get in your java app or persistence model, 
these limitations apply always.

Cya.


-----Mensaje original-----
De: GEDA [mailto:[EMAIL PROTECTED] 
Enviado el: Miércoles, 12 de Septiembre de 2007 06:50 a.m.
Para: user@struts.apache.org
Asunto: Call Oracle stored function using Hibernate


Hi. I am using Spring, Struts 2, Hibernate and Oracle as DB. Until now
everything worked ok since I only needed full entity objects but now I have
to call some stored functions from the DB using the hibernate api. Until now
I have used the following syntax: Query q =
getEntityManager().createQuery(). 

Can you give me an example please on how to call a stored function ?

Thank you.
-- 
View this message in context: 
http://www.nabble.com/Call-Oracle-stored-function-using-Hibernate-tf4429022.html#a12634650
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to