ibatisドロップストレージ・プロシージャによる複数の戻り値の取得

2951 ワード

Daoコード
@Repository("AlipayDAO")
public class AlipayDAOImpl extends BaseDAOImpl<TAlipay> implements IAlipayDAO {

    public AlipayDAOImpl() {
        super("TAlipay");
    }
	public String saveByProcedure(Map<String,Object> alipay) {
		getSqlMapClientTemplate().queryForObject(
                "TAlipay.sp_alipay_add_auto", alipay);
		return alipay.get("ERR_CODE")+"|"+alipay.get("ERR_INFO");
	}
}



xml
 
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >


	<parameterMap class="map" id="alipay">
	   <parameter property="notifyTime" jdbcType="TIME" javaType="java.util.Date" mode="IN"/>
	   <parameter property="tradeNo" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>
	   <parameter property="outTradeNo" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>
	   <parameter property="totalFee" jdbcType="DOUBLE" javaType="java.lang.Double" mode="IN"/>
	   <parameter property="gmtCreate" jdbcType="TIME" javaType="java.util.Date" mode="IN"/>
	   <parameter property="gmtPayment" jdbcType="TIME" javaType="java.util.Date" mode="IN"/>
	   <parameter property="extraCommonParam" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>
	   <parameter property="buyerId" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>
	   <parameter property="buyerEmail" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>
	   <parameter property="ERR_CODE" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT"/>
	   <parameter property="ERR_INFO" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT"/>
	</parameterMap>

 
 
outのpropertyは、ストレージ・プロシージャで定義されたものと同じように大文字でなければなりません.
 
 
The jdbcType attribute can be set to any string value that matches a constant in the
JDBC Types class.
jdbcTypeはjavaのはずです.sql.Typeのフィールド名
 
 
Java only has one Date value type
(java.util.Date), but most SQL databases usually have at least three different
types. Because of this you might want to specify explicitly that your column type is
DATE versus DATETIME.