java中使用mybatis调用存储过程,拿到返回值(单参数返回值)

service业务层调用dao层

注意:返回值直接从对象里获取 不需要拿对象接收再获取

dao.uspGetUser(userPO);//对象封装了存储过程的入参和出参
count = userPO.getCount();    //count 是存储过程的返回值

dao层接口

public interface userDao {
    Integer uspGetUser(UserPO userPO);
}

mapper配置文件

<select id="uspGetUser" statementType="CALLABLE" parameterType="com.entity.UserPO" resultType="integer">
	call usp_get_user(
	#{id,mode=IN,jdbcType=VARCHAR},
	#{name,mode=IN,jdbcType=VARCHAR},
	#{count,mode=OUT,jdbcType=VARCHAR});
</select>

猜你喜欢

转载自blog.csdn.net/qq_38187437/article/details/84872758