java - Hibernate 4 - Call stored procedure having IN as well as OUT parameters -


i researched how call stored procedure using hibernate 4 session object in & out params, no use.

finally got clue related "sessionimpl". using object can connection object.

using connection object can call preparecall() method, support in/out params of procedure.

following sample snippet.

        map<string, string> returnmap = new hashmap<string, string>();          session session = sessionfactory.getcurrentsession();         connection connobj = ((sessionimpl)session).connection();         callablestatement connstmt = connobj.preparecall("{ call schema.pkg_name.sp_name(?,?,?) }");         connstmt.setlong(1, 123456);          connstmt.registeroutparameter(2, java.sql.types.varchar);         connstmt.registeroutparameter(3, java.sql.types.varchar);         connstmt.execute();          if(connstmt != null && connstmt.getstring(2).equalsignorecase("y")) {             returnmap.put("returnid", exceptionconstants.success_status);             returnmap.put("returnmessage", connstmt.getstring(3));           } else {             returnmap.put("returnid", exceptionconstants.failed_status);             returnmap.put("returnmessage", connstmt.getstring(3));         } 


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -