1、xml
<parameterMap id="newFailMap" class="java.util.HashMap">
<parameter property="returnUserId" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"></parameter>
<parameter property="businessRetrunDesc" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"></parameter>
<parameter property="detailList" jdbcType="ARRAY" javaType="java.util.List" mode="IN"
typeHandler="com.sinolife.claim.basic.dto.ImageFailedDetailVinArrayTypeHandler"/>
<parameter property="flag" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT"></parameter>
<parameter property="message" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT"></parameter>
</parameterMap>
<procedure id="newFail" parameterMap="newFailMap">
{ call l_claim_public_pkg.add_image_failed_info(?,?,?,?,?) }
</procedure>
<parameter property="returnUserId" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"></parameter>
<parameter property="businessRetrunDesc" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"></parameter>
<parameter property="detailList" jdbcType="ARRAY" javaType="java.util.List" mode="IN"
typeHandler="com.sinolife.claim.basic.dto.ImageFailedDetailVinArrayTypeHandler"/>
<parameter property="flag" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT"></parameter>
<parameter property="message" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT"></parameter>
</parameterMap>
<procedure id="newFail" parameterMap="newFailMap">
{ call l_claim_public_pkg.add_image_failed_info(?,?,?,?,?) }
</procedure>
2、java
public void newFail(HashMap pMap) {
getSqlMapClientTemplate().queryForList(FailDao.class.getName()+".newFail", pMap);
}
getSqlMapClientTemplate().queryForList(FailDao.class.getName()+".newFail", pMap);
}
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;
import oracle.sql.STRUCT;
import oracle.sql.StructDescriptor;
import com.ibatis.sqlmap.engine.type.BaseTypeHandler;
import com.ibatis.sqlmap.engine.type.TypeHandler;
import com.sinolife.claim.basic.util.CommonFunctions;
import com.sinolife.sf.framework.comm.ConnectionUtil;
public class ImageFailedDetailVinArrayTypeHandler extends BaseTypeHandler implements TypeHandler {
@Override
public Object getResult(ResultSet arg0, String arg1) throws SQLException {
return null;
}
@Override
public Object getResult(ResultSet arg0, int arg1) throws SQLException {
return null;
}
@Override
public Object getResult(CallableStatement arg0, int arg1) throws SQLException {
return null;
}
/**
* 构造Oracle能识别的Array
*/
@Override
public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
// 本连接池连接
Connection con = ps.getConnection();
// 获取原生Oracle 连接
con = ConnectionUtil.getNativeConnection(con);
ArrayList<ImageFailedDetailDto> list = (ArrayList<ImageFailedDetailDto>) parameter;
ARRAY array;
try {
array = getArray(con, "IMAGCDE.IMAGE_FAILED_DETAILE_OBJ", "IMAGCDE.IMAGE_FAILED_DETAILE_LIST",list);
ps.setArray(i, array);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 创建oracle中的Array
* @param con
* @param OracleObj
* @param Oraclelist
* @param listData
* @return
* @throws Exception
*/
private ARRAY getArray(Connection con, String OracleObj, String Oraclelist, List<ImageFailedDetailDto> listData) throws Exception {
ARRAY array = null;
ArrayDescriptor desc = ArrayDescriptor.createDescriptor(Oraclelist, con);
StructDescriptor structdesc = new StructDescriptor(OracleObj, con);
if (listData != null && listData.size() > 0) {
STRUCT[] structs = new STRUCT[listData.size()];
for (int i = 0; i < listData.size(); i++) {
Object[] result = { (listData.get(i)).getDocumentId(),
CommonFunctions.isEmpty((listData.get(i)).getReturnUserId())?"":(listData.get(i)).getReturnUserId(),
(listData.get(i)).getReturnTime(),
"",
"",
CommonFunctions.isEmpty((listData.get(i)).getReturnReason())?"":(listData.get(i)).getReturnReason(),
CommonFunctions.isEmpty((listData.get(i)).getBusinessRetrunDesc())?"":(listData.get(i)).getBusinessRetrunDesc(),
CommonFunctions.isEmpty((listData.get(i)).getFileId())?"":(listData.get(i)).getFileId(),
CommonFunctions.isEmpty((listData.get(i)).getImage())?"":(listData.get(i)).getImage()
};
structs[i] = new STRUCT(structdesc, con, result);
}
array = new ARRAY(desc, con, structs);
}
return array;
}
@Override
public Object valueOf(String arg0) {
return null;
}
}
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;
import oracle.sql.STRUCT;
import oracle.sql.StructDescriptor;
import com.ibatis.sqlmap.engine.type.BaseTypeHandler;
import com.ibatis.sqlmap.engine.type.TypeHandler;
import com.sinolife.claim.basic.util.CommonFunctions;
import com.sinolife.sf.framework.comm.ConnectionUtil;
public class ImageFailedDetailVinArrayTypeHandler extends BaseTypeHandler implements TypeHandler {
@Override
public Object getResult(ResultSet arg0, String arg1) throws SQLException {
return null;
}
@Override
public Object getResult(ResultSet arg0, int arg1) throws SQLException {
return null;
}
@Override
public Object getResult(CallableStatement arg0, int arg1) throws SQLException {
return null;
}
/**
* 构造Oracle能识别的Array
*/
@Override
public void setParameter(PreparedStatement ps, int i, Object parameter, String jdbcType) throws SQLException {
// 本连接池连接
Connection con = ps.getConnection();
// 获取原生Oracle 连接
con = ConnectionUtil.getNativeConnection(con);
ArrayList<ImageFailedDetailDto> list = (ArrayList<ImageFailedDetailDto>) parameter;
ARRAY array;
try {
array = getArray(con, "IMAGCDE.IMAGE_FAILED_DETAILE_OBJ", "IMAGCDE.IMAGE_FAILED_DETAILE_LIST",list);
ps.setArray(i, array);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 创建oracle中的Array
* @param con
* @param OracleObj
* @param Oraclelist
* @param listData
* @return
* @throws Exception
*/
private ARRAY getArray(Connection con, String OracleObj, String Oraclelist, List<ImageFailedDetailDto> listData) throws Exception {
ARRAY array = null;
ArrayDescriptor desc = ArrayDescriptor.createDescriptor(Oraclelist, con);
StructDescriptor structdesc = new StructDescriptor(OracleObj, con);
if (listData != null && listData.size() > 0) {
STRUCT[] structs = new STRUCT[listData.size()];
for (int i = 0; i < listData.size(); i++) {
Object[] result = { (listData.get(i)).getDocumentId(),
CommonFunctions.isEmpty((listData.get(i)).getReturnUserId())?"":(listData.get(i)).getReturnUserId(),
(listData.get(i)).getReturnTime(),
"",
"",
CommonFunctions.isEmpty((listData.get(i)).getReturnReason())?"":(listData.get(i)).getReturnReason(),
CommonFunctions.isEmpty((listData.get(i)).getBusinessRetrunDesc())?"":(listData.get(i)).getBusinessRetrunDesc(),
CommonFunctions.isEmpty((listData.get(i)).getFileId())?"":(listData.get(i)).getFileId(),
CommonFunctions.isEmpty((listData.get(i)).getImage())?"":(listData.get(i)).getImage()
};
structs[i] = new STRUCT(structdesc, con, result);
}
array = new ARRAY(desc, con, structs);
}
return array;
}
@Override
public Object valueOf(String arg0) {
return null;
}
}
3、pkg
PROCEDURE add_image_failed_info(p_return_user_id IN VARCHAR2,
p_business_retrun_desc IN VARCHAR2,
p_image_faild_detail_lst IN IMAGCDE.IMAGE_FAILED_DETAILE_lIST,
p_flag OUT VARCHAR2,
p_message OUT VARCHAR2)
IS
v_image_failed_obj IMAGCDE.IMAGE_FAILED_OBJ;
BEGIN
p_flag := 'Y';
v_image_failed_obj := IMAGCDE.IMAGE_FAILED_OBJ(p_return_user_id,
'N',
p_business_retrun_desc,
p_image_faild_detail_lst);
l_image_claim_interface.add_image_failed_info(v_image_failed_obj,p_flag,p_message);
EXCEPTION
WHEN OTHERS THEN
DECLARE
v_error_code VARCHAR2 (4000);
v_comments VARCHAR2 (4000);
v_program_id VARCHAR2 (50) := 'add_image_failed_info';
v_error_message VARCHAR2 (4000);
BEGIN
v_error_code := NULL;
v_comments := NULL;
pub_error_handle.exception_no_raise(v_program_id,
v_error_code,
v_comments,
v_error_message);
p_flag := 'N';
p_message := 'add_image_failed_info发生后台异常,具体原因请查看后台异常处理日志。';
END;
END add_image_failed_info;
p_business_retrun_desc IN VARCHAR2,
p_image_faild_detail_lst IN IMAGCDE.IMAGE_FAILED_DETAILE_lIST,
p_flag OUT VARCHAR2,
p_message OUT VARCHAR2)
IS
v_image_failed_obj IMAGCDE.IMAGE_FAILED_OBJ;
BEGIN
p_flag := 'Y';
v_image_failed_obj := IMAGCDE.IMAGE_FAILED_OBJ(p_return_user_id,
'N',
p_business_retrun_desc,
p_image_faild_detail_lst);
l_image_claim_interface.add_image_failed_info(v_image_failed_obj,p_flag,p_message);
EXCEPTION
WHEN OTHERS THEN
DECLARE
v_error_code VARCHAR2 (4000);
v_comments VARCHAR2 (4000);
v_program_id VARCHAR2 (50) := 'add_image_failed_info';
v_error_message VARCHAR2 (4000);
BEGIN
v_error_code := NULL;
v_comments := NULL;
pub_error_handle.exception_no_raise(v_program_id,
v_error_code,
v_comments,
v_error_message);
p_flag := 'N';
p_message := 'add_image_failed_info发生后台异常,具体原因请查看后台异常处理日志。';
END;
END add_image_failed_info;