//存储过程,这里非常简单,存储过程的作用就是拿到传入的ID
CREATE or replace PROCEDURE test1(
in idNum int ,
out total int
)
BEGIN
SELECT id
FROM admin_advertiser
WHERE id=idNum
into total;
end ;
//mapper方法
void getProcedure(Map<String,Object> params);
//XML文件
<!--void getProcedure(Map<String,Object> params);-->
<select id="getProcedure" statementType="CALLABLE" >
{call test11(
#{idNum,mode=IN,jdbcType =INTEGER},
#{total,mode=OUT,jdbcType =INTEGER}
)}
</select>
//测试类
@Test
public void jj(){
SqlSession sqlSession = sqlSessionFactory.openSession();
// 创建代理对象
AdvertiserDOMapper advertiserDOMapper=sqlSession.getMapper(AdvertiserDOMapper.class);
Map<String,Object> map =new HashMap<>();
map.put("idNum",1);
advertiserDOMapper.getProcedure(map);
System.out.println("------------------");
System.out.println(map.get("total") );
System.out.println("------------------");
}
下面得到的结果是:1
// ------------------
//1
//------------------