一、调用存储过程:
1)statementType="CALLABLE":表示要调用存储过程
2){call procedure_name(params)}
<select id= " selectUserPage” statement Type=” CALLABLE ” useCache=” false ”
resultMap=” userMap ”>
{call select user page(
#{userName, mode=IN},
#{offset, mode=IN},
#{limit, mode=IN} ,
#{total, mode=OUT, jdbcType=BIGINT}
)}
</select>
案例:
CREATE PROCEDURE select_country(IN p_in int)
BEGIN
SELECT * from country WHERE id=p_in;
END;
<select id="selectByIdCall" statementType="CALLABLE" useCache="false" resultMap="BaseResultMap" databaseId="mysql"> { call select_country( #{id,mode=IN} )} </select>
注:
1、OUT 模式的参数必须指定jdbcType
2、存储过程方式不支持MyBatis 的二级缓存,useCache 属性设