We use iBatis + Spring intensively. Everything we get from the DB is fetched via stored procedures. At times when troubleshooting an issue we want to know the exact parameters that were sent to the SP and SP name that was executed. Currently we do this by debugging the code (which is a pain). We would like to add some sort of logging to iBatis so it prints out name of the SP + parameter values. We use log4j and following is our iBatis structure.
Mapping:
<procedure id="getReportData" parameterMap="getReportDataCall">
{call get_rpt (?,?,?,?)}
</procedure>
<parameterMap id="getReportDataCall" class="map">
<parameter property="type" jdbcType="String" javaType="java.lang.String" mode="IN"/>
<parameter property="month" jdbcType="Int" javaType="java.lang.Integer" mode="IN"/>
<parameter property="Result0" jdbcType="ORACLECURSOR" javaType="java.sql.ResultSet" mode="OUT" resultMap="result1"/>
<parameter property="Result1" jdbcType="ORACLECURSOR" javaType="java.sql.ResultSet" mode="OUT" resultMap="result2"/>
</parameterMap>
<resultMap id="select-first-result-hq" class="VO">
<result property="column1" column="columna"/>
<result property="column2" column="columnb"/>
</resultMap
Calling iBatis from DAO
HashMap parm = new HashMap ();
parm.put("type", type_val);
parm.put("month", month_val);
getSqlMapClientTemplate().queryForList("mymappingName.getReportData", parm);
As you see the parameters are just in a HashMap
. I could make a class+method of my own which takes in the HashMap
and procedure name as parameters and just prints out all the key/value pairs of the hashmap and the procedure name to the log. However, if I do this...I will have to add that call to all my DAO's before I call the SP.
Is there any simpler solution to this? that would avoid me touching all my code again?