hi I am very new to Hibernate. I am writing DAOs using Hibernate to access a complex SP which is having 17 IN Params 4 Out Params and and the Result Set contains 6 param. ( SP IN/Out param is mentioned below) As of my knowledge we will be having Hibernate Mapping file which will contain mapping to input/output parameters to its corresponding column name in table. Consider The Store Procedure name is XXX. Please let me know how to call this SP. The return type wil be Array of values and the input is DocSearchParams
Field Name SQL TypePosition AllowsCI Table View Data Field in DB DID DEC(15)1N0501 DT_ID DATE DATE2N0501 DDATE DTYPE CHAR(2)3N0801 D_TYP M_TYPE CHAR(2)4N0501 MPE DI_TYPE CHAR(2)5N0501 DPE USATE Time Stamp6N0801 CRMESTAMP
Can i write a mapping file like this <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > <hibernate-mapping> <sql-query name="SP0039_SP" callable="true"> <return alias="documentsVO" class="com.program.fina.DocumentsVO"> </return> { call XXX(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) } </sql-query> </hibernate-mapping> 1) hibernate Gurus Please help me to solve this issue. 2) Please let me know how to access the result set from DAO. Regards S.Jacob [ July 25, 2006: Message edited by: jacob selvaraj ]
Scott Johnson
Ranch Hand
Joined: Aug 24, 2005
Posts: 518
posted
0
You can't call this procedure as a Hibernate named query.
Thanks Scott and Mark for your replies. The problem is I am Just Writing an interface which is Suppose to use that Stored Procedure. The Stored Procedure is written by third party. 1) Please let me know the way to access the above Stored Procedure with out changing the Stored Procedure. ( With Syntax Possible) 2) Please let me know what the configuration parameter in Hibernate Mapping file.
Regards S.Jacob
jacob selvaraj
Greenhorn
Joined: Jul 24, 2006
Posts: 4
posted
0
Hi Can i Call Stored Procedure like below as you said. -------------------------------------------- session = HibernateUtil.getInstance(CONFIG_FILE_LOCATION).getCurrentSession(); getIndexTrans = session.beginTransaction(); CallableStatement callableStatement = session.connection().prepareCall("{call SP0039(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}"); callableStatement.setString("FUNCTION_CODE", emptyString(2)); callableStatement.setString("LOGCL_RUN_DTE", emptyString(NUM_TEN)); callableStatement.setString("SCHD_CMPNT_CDE", emptyString(1)); callableStatement.setString("ENV_TYPE_CDE", emptyString(1)); callableStatement.setString("USER_ID", emptyString(NUM_EIGHT)); callableStatement.commit(); Regards S.Jacob
Scott Johnson
Ranch Hand
Joined: Aug 24, 2005
Posts: 518
posted
0
CallableStatement doesn't have a commit() method. You should call executeUpdate() to run the sql.
jacob selvaraj
Greenhorn
Joined: Jul 24, 2006
Posts: 4
posted
0
Hi all,
Here is the DAO to call SP. 1) After doing a preparecall i am setting input parameter. callableStatement.setString(FUNCTION_CODE, " "); But i am getting the below Exception in the above setString Statement. ---------- Exception: ---------- com.ibm.db2.jcc.b.SqlException: JDBC 3 method called - not yet supported at com.ibm.db2.jcc.b.bd.setString(bd.java:961) at org.apache.commons.dbcp.DelegatingCallableStatement.setString (DelegatingCallableStatement.java:221) Please help me in this regard.
Version: -------- Hibernate 3.0 DB2 Version 8.1.6.4