xml 中的代码
<select id="getData" statementType="CALLABLE" parameterType="Map">
{
call schamename.spname(
#{p_ISN, mode=IN, jdbcType=VARCHAR},
#{p_DB, mode=IN, jdbcType=VARCHAR},
#{p_CUR_RESULT, mode=OUT, jdbcType=CURSOR, resultMap=cursorMap},
#{p_RET, mode=OUT, jdbcType=INTEGER},
#{p_MSG, mode=OUT, jdbcType=VARCHAR}
)
}
</select>
<resultMap type ="java.util.HashMap" id= "cursorMap">
<result column ="ISN" property="ISN" />
<result column ="BUILD" property="BUILD" />
<result column ="APPLEP_N" property="APPLEP_N" />
</resultMap >
<select id="insertLog" statementType="CALLABLE" parameterType="HashMap">
{
call schamename.spname(
#{P_USERID, mode=IN, jdbcType=VARCHAR},
#{P_CLIENT_IP, mode=IN, jdbcType=VARCHAR},
#{P_HOSTNAME, mode=IN, jdbcType=VARCHAR},
#{P_PROJECT_CODE, mode=IN, jdbcType=VARCHAR},
#{P_SERVER_IP, mode=IN, jdbcType=VARCHAR},
#{P_URL, mode=IN, jdbcType=VARCHAR},
#{P_PAGENAME, mode=IN, jdbcType=VARCHAR},
#{P_ACTION, mode=IN, jdbcType=VARCHAR},
#{P_STARTIME, mode=IN, jdbcType=DATE},
#{P_ENDTIME, mode=IN, jdbcType=DATE},
#{P_EXETIME, mode=IN, jdbcType=INTEGER},
#{P_REQUEST_TYPE, mode=IN, jdbcType=INTEGER},
#{P_SHOP, mode=IN, jdbcType=VARCHAR},
#{P_RET, mode=OUT, jdbcType=INTEGER},
#{P_MSG, mode=OUT, jdbcType=VARCHAR})
}
</select>
<insert id="addData" statementType="CALLABLE" parameterType="Map">
{
call schamename.spname(
#{P_MO, mode=IN, jdbcType=VARCHAR},
#{P_TQTY, mode=IN, jdbcType=INTEGER},
#{P_OP, mode=IN, jdbcType=VARCHAR},
#{P_RET, mode=OUT, jdbcType=INTEGER},
#{P_MSG, mode=OUT, jdbcType=VARCHAR})
}
</insert>
service 中调用
@Override
public String updateData(Map<String, Object> params,User user) throws Exception {
String result = "";
SqlSession session = null;
try {
String op = user.getUserID();
String mo = params.remove("MO").toString().trim().toUpperCase();
params.put("P_MO", mo);
Object tqty = params.remove("TQTY");
params.put("P_TQTY", tqty);
params.put("P_OP", op);
session = SessionFactory.getSqlSession(user.getDbid());
IORT_MaintainMapper mapper = session.getMapper(IORT_MaintainMapper.class);
mapper.addData(params);
if ("0".equals(String.valueOf(params.get("P_RET"))))
{
result = ConstantList.getErrorStringAsMap("update mo: " + mo + " failed!Cause by: " + params.get("P_MSG"));
return result;
}
session.commit();
result = ConstantList.getSuccessStringAsMap(ConstantList.UPDATE_OK_RESULT);
return result;
} catch (Exception e) {
e.printStackTrace();
session.rollback();
result = ConstantList.getSuccessStringAsMap(ConstantList.UPDATE_FAIL_RESULT);
return result;
} finally {
if(session != null){
session.close();
}
}
}