hi,
we're trying to write a generic DAO impl. to wrap calls to several dozen stored procs that all have varying IN parameters, but the same OUT parameters. We keep getting failures based on missing parameter declarations. Using Spring 2.5.1
The DAO impl is as follows:
which is being exercised with the following test:Code:public class GenericStoredProcedureDAOImpl implements GenericStoredProcedureDAO { private Map<String, SimpleJdbcCall> spMap = new HashMap<String, SimpleJdbcCall>(); @Autowired private DataSource dataSource; public StoredProcReturn call(String spName, Map<String, Object> parameters) throws DataAccessException { // is the compiled call already in the map? SimpleJdbcCall sp = spMap.get(spName); if (sp == null) { // create and add to the map sp = new SimpleJdbcCall(dataSource) .withProcedureName(spName); // .withoutProcedureColumnMetaDataAccess() // .useInParameterNames("j_user_id") // .declareParameters( // new SqlParameter("j_user_id", Types.NUMERIC), // new SqlOutParameter("j_employee_id", Types.NUMERIC), // new SqlOutParameter(J_RET_VAL, Types.INTEGER), // new SqlOutParameter(J_INTERNAL_MESSAGE, Types.VARCHAR), // new SqlOutParameter(J_EXTERNAL_MESSAGE, Types.VARCHAR) // ); sp.compile(); spMap.put(spName, sp); } // execute sp Map<String, Object> out = sp.execute(parameters); // set return vals StoredProcReturn spReturn = new StoredProcReturn(); spReturn.setRetVal((Integer) out.get(J_RET_VAL)); spReturn.setInternalMessage((String) out.get(J_INTERNAL_MESSAGE)); spReturn.setExternalMessage((String) out.get(J_EXTERNAL_MESSAGE)); return spReturn; } }
The relevant SP declaration in Oracle for the above test is as follows:Code:public void testCallNotFailing() { Map<String, Object> p = new HashMap<String, Object>(); p.put("j_user_id", 1151l); StoredProcReturn spr = dao.call("employee_pkg.get_employee_id", p); assertFalse(spr.hasFailed()); assertNull(spr.getInternalMessage()); assertNull(spr.getExternalMessage()); }
and the log output is this:Code:PROCEDURE GET_EMPLOYEE_ID ( j_user_id IN ACCOUNT_USER.USER_ID%TYPE, j_employee_id OUT VARCHAR2, j_ret_val OUT NUMBER, j_internal_message OUT VARCHAR2, j_external_message OUT VARCHAR2);
If I uncomment the param declarations in the DAO, it works, but of course this makes the DAO method applicable to only a single SP and not the dozens we want it to be used for.Code:[22 Feb 13:41:37,534] DEBUG core.metadata.CallMetaDataProviderFactory - Using org.springframework.jdbc.core.metadata.OracleCallMetaDataProvider [22 Feb 13:41:37,534] DEBUG core.metadata.CallMetaDataProvider - Retrieving metadata for /MYSCHEMA/EMPLOYEE_PKG.GET_EMPLOYEE_ID [22 Feb 13:41:37,953] DEBUG core.simple.SimpleJdbcCall - Compiled stored procedure. Call string is [{call EMPLOYEE_PKG.GET_EMPLOYEE_ID()}] [22 Feb 13:41:37,955] DEBUG core.simple.SimpleJdbcCall - SqlCall for procedure [employee_pkg.get_employee_id] compiled [22 Feb 13:41:37,956] WARN core.metadata.CallMetaDataContext - Unable to locate the corresponding parameter for "j_user_id" in the parameters used: [] [22 Feb 13:41:37,956] DEBUG core.metadata.CallMetaDataContext - Matching {j_user_id=1151} with {} [22 Feb 13:41:37,956] DEBUG core.metadata.CallMetaDataContext - Found []
Anything I'm missing here?
Cheers,


Reply With Quote
